Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- /**
- * Created by Maciek on 2016-03-14.
- */
- public class FileReader {
- private FileOutputStream fout;
- private FileInputStream fin;
- private String x;
- private TextEditor textEditor = new TextEditor();
- public String y = "";
- public void saveFile(String txt) {
- try {
- fout = new FileOutputStream("test.txt");
- } catch (IOException e) {
- System.out.println("Blad wejscia-wyjscia");
- System.exit(-1);
- }
- DataOutputStream out = new DataOutputStream(fout);
- try {
- out.writeBytes(txt);
- } catch (IOException i) {
- System.out.println("Probujesz zapisac pusty plik.");
- }
- }
- public void readFile() {
- try {
- fin = new FileInputStream("test.txt");
- BufferedReader brin = new BufferedReader(new InputStreamReader(fin));
- while ((x = brin.readLine()) != null) {
- System.out.println(x);
- y += x +"\n";
- }
- } catch (IOException e) {
- System.out.println("-1");
- System.exit(-1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment