import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class NewClass {
public static void main(String[] args) {
String linha = null;
List
File arq = new File("C:\\Teste1", "Saida.txt");
//Inicia leitura do arquivo
try {
FileReader fileReader = new FileReader("C://Teste1/User2.txt");
BufferedReader bufferedReader = new BufferedReader(fileReader);
while ((linha = bufferedReader.readLine()) != null) {
result.add(linha);
}
fileReader.close();
bufferedReader.close();
} catch (IOException e) {
System.out.println("erro");
}
//Inicia gravação do arquivo de saída
try {
arq.createNewFile();
FileWriter fileWriter = new FileWriter(arq, false);
PrintWriter printWriter = new PrintWriter(fileWriter);
for (int i = 0; i < result.size(); i++) {
printWriter.println(result.get(i));
}
printWriter.flush();
printWriter.close();
} catch (IOException e) {
System.out.println("erro");
}
}
}
Nenhum comentário :
Postar um comentário