How to read a file character by character? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to read a file character by character?

21st Feb 2016, 8:38 AM
Siva kumar
1 Answer
+ 3
FileInputStream fileInput = new FileInputStream("file.txt"); int r; while ((r = fileInput.read()) != -1) { char c = (char) r; // do something with the character c } fileInput.close();
19th May 2016, 12:56 PM
James Flanders