Buddy I picked up an example comic
Manipulative.java.:
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();
}
}
Main java.:
package gomes.fernando.robson;
import java.io.IOException;
public class Principal {
public static void main(String args[]) throws IOException {
String path = "/tmp/file.txt";
ManipuladorArquivo.escritor(path);
ManipuladorArquivo.leitor(path);
}
}
Well the main class will use the Manipulative class.java which has the function to read and write the file. Good you just treat the reading with the visual part, xml ...
Would you like a more detailed explanation of the above code?
Original article: https://www.devmedia.com.br/leitura-e-escrita-de-arquivos-de-texto-em-java/25529
Sorry if I don’t clarify, what I was wanting is not the code to read and write was how to leave my application in the list, in the option to read text file for when user press a text file my application appearing the options to open with it, but thank you for the encouragement thank you even more if you can help me at this particular point.
– Leandro Capacio