0

How i can read a file

24th Dec 2019, 11:00 PM
Anas Melhem
Anas Melhem - avatar
2 Antworten
0
String fileName = yourFile.txt; File f = new File(fileName); try { BufferedReader read = new BufferedReader(new FileReader(fileName)); String line = ""; int lineCounter = 1; while( (line = read.readLine()) != null) { System.out.println(lineCounter+"\t "+line); lineCounter++; } read.close(); } catch (IOException e) { System.out.println("encounter an error while reading "); } I can provide code with comments if needed but this is basically boilerplate
24th Dec 2019, 11:09 PM
HNNX 🐿
HNNX 🐿 - avatar
0
thank you my friend that's I need ❤️
24th Dec 2019, 11:20 PM
Anas Melhem
Anas Melhem - avatar