forked from Annex5061/java-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileHandler.java
36 lines (30 loc) · 898 Bytes
/
fileHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package gomes.fernando.robson;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class ManipuladorArquivo {
public static void leitor(String path) throws IOException {
BufferedReader buffRead = new BufferedReader(new FileReader(path));
String linha = "";
while (true) {
if (linha != null) {
System.out.println(linha);
} else
break;
linha = buffRead.readLine();
}
buffRead.close();
}
public static void escritor(String path) throws IOException {
BufferedWriter buffWrite = new BufferedWriter(new FileWriter(path));
String linha = "";
Scanner in = new Scanner(System.in);
System.out.println("Escreva algo: ");
linha = in.nextLine();
buffWrite.append(linha + "\n");
buffWrite.close();
}
}