Quote:
Originally Posted by chetah
bd.txt
D2333 How to program in Java r IN 454554 Dietal & Dietal Prentice Hall
G4547 Java in a Nut Shell c 343345 David Flagman O'Reilly 03-02-08
END
678764 John Smith #5 Hill View, Rose Hall Undergrad 5
END
Thank you very much, the tab works fine. The above is an example of the data I am working with. Having gotten the tab to work, reading in the data becomes a problem. Tell me am I going wrong.
-
String v = input.next() //read first value in data
-
int count = 0;
-
while(!(v.equals("END")))// check for end
-
{
-
book[count] = new Book (v, input.next() etc.)
-
count++;
-
v = input.next();
-
if(v.equals("END"){
-
break;
-
}}
-
-
int x = input.nextInt()
-
while(x!=0){
-
borrower[i] = new Borrower(etc.)
-
i++;
-
x = input.nextInt();
-
String p = input.next()
-
if(p.equals("END"){
-
break;
-
}}
-
What is wrong with my logic here? Even if I get the file to compile, when I try to print I get null.
OK, fist of all: Both r035198x and I have now added
[CODE]...[/code] to your posts. Please use them yourself from now on.
Now, where do you try to print something and what printout would you expect? Oh, and I'm not sure if you know that, but
input.next() will read the next Word (so whatever comes until the next whitespace character) and not more. You may want to use
input.nextLine().
Greetings,
Nepomuk