-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArquivosReader.java
More file actions
41 lines (37 loc) · 993 Bytes
/
ArquivosReader.java
File metadata and controls
41 lines (37 loc) · 993 Bytes
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
37
38
39
40
41
package util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
public class ArquivosReader {
/**
* <p>Faz a leitura de um arquivo e retorna todas as linhas em uma ArrayList<String><p>
*
* @param caminho
* @param arquivo
* @return
*/
public ArrayList<String> arquivoLinhas(File arquivo) {
String linha = "";
ArrayList<String> arquivoLinhas = new ArrayList<String>();
FileReader arq;
try {
arq = new FileReader(arquivo);
BufferedReader lerArq = new BufferedReader(arq);
try {
while (linha != null) {
linha = lerArq.readLine();
arquivoLinhas.add(linha);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
arq.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println("Arquivo " + arquivo.getAbsolutePath() + " não existe: " + e);
}
return arquivoLinhas;
}
}