*
The moose likes Beginning Java and the fly likes Program not correctly reading from a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program not correctly reading from a text file" Watch "Program not correctly reading from a text file" New topic
Author

Program not correctly reading from a text file

Gulshan Singh
Ranch Hand

Joined: Apr 22, 2009
Posts: 41
The following code is part of my Flash card program where the user can have two text files, one called questions and the other called answers, and then the program will display the questions and the user can see if he can get the right answer.

This is just the loading of the cards, not the whole program. The problem is not every line in the text file is being loaded. Try it yourself using two text files with the same number of lines, and if the text file was something like,
word1
word2
word3
word4

The ArrayList qlines would be something like
word1
word2
word4
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4163
    
  21

Gulshan Singh wrote:



For each round in the loop, you are reading from the buffques twice - once in the while condition, and once in the qlines.add() line. Take the second one out and store tempstr into qlines.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program not correctly reading from a text file
 
Similar Threads
Compare Two Text Files
Want to write a combined text file, but nothing happens..
application "freezing"
algorithm question about array
why doesn't this work?