Skip to content

Instantly share code, notes, and snippets.

@mick001
Created August 29, 2015 15:19
My first java programs. Part 3
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class GetOutData
{
private String content;
// if you need to print a string
public GetOutData(String output)
{
this.content = output;
}
public void writeString(String path)
{
try
{
File file = new File(path);
if(!file.exists())
{
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(this.content);
bw.close();
}catch(IOException e)
{
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment