By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,032 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,032 IT Pros & Developers. It's quick & easy.

help in java

P: 1
can anyone tell me how to read a file character by character.thank you
Nov 21 '06 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,652
Try this:

Expand|Select|Wrap|Line Numbers
  1. Scanner IN = new Scanner("fileName.txt");
  2. string input = IN.nextLine();
  3. process(input.charAt(0));
  4. process(input.charAt(1));
  5. process(input.charAt(2));
  6. // and so on...
I was never very good at file input/output in Java...since I used Java4 with BufferedReaders and Streams and all sort of craziness.
Nov 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.