Skip to content

Instantly share code, notes, and snippets.

@mick001
Created August 29, 2015 15:19

Revisions

  1. mick001 created this gist Aug 29, 2015.
    39 changes: 39 additions & 0 deletions first_program3.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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();
    }
    }


    }