- Where Developers Learn, Share, & Build Careers
I am trying to read from a text file and I am using input to create several different objects . I do not want to read clearly after the file is empty, so I have a method empty () which reads to the point that I want in the file and then reads the test for the next line and zero.
The problem is that if it is not empty then the file is read ... but in the second line from the next line, I read the first line to test, but can not read it again.
My current idea is to create a dummy object to test it and actually use the same, second object to use. But it is very useless and I think there should be a better way .... Thanks for everyone!
Notes: The method that reads is not the same method that is checking the empty bufferedReader is being used for all the objects because otherwise I would re-enter the file name from the user , Which I do not want to do.
Why do not you stick to the phrase BufferedReader ? Instead of asking that the file is empty, and if it is not empty then get the next item, ask for the next item directly, and return the method if there are no items. Very simple: Otherwise, you
while ((line = reader. Readline ())! = Null {...}
sign () To mark your current status, read some lines further, and then
reset () . / Html>
Comments
Post a Comment