// Write x to file
public void writeFile(String x, String file){
try{
// Create file
FileWriter fstream = new FileWriter(file);
// Create Writer
BufferedWriter out = new BufferedWriter(fstream);
// Write x to the file
out.write(x);
//Close the output stream
out.close();
}catch (Exception e){
//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
Showing posts with label write to file. Show all posts
Showing posts with label write to file. Show all posts
Tuesday, May 8, 2012
Sunday, May 6, 2012
.NET C# Write to a file
public static bool WriteToFile(string fileName, string fileContent)
{
fileName = fileName;
System.IO.TextWriter tw;
try
{
tw = new System.IO.StreamWriter(fileName, true);
tw.WriteLine(fileContent);
tw.Close();
return true;
}
catch{}
return false;
}
{
fileName = fileName;
System.IO.TextWriter tw;
try
{
tw = new System.IO.StreamWriter(fileName, true);
tw.WriteLine(fileContent);
tw.Close();
return true;
}
catch{}
return false;
}
Subscribe to:
Posts (Atom)