Created
August 29, 2015 15:19
My first java programs. Part 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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