Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,382 members, 7,954,545 topics. Date: Friday, 20 September 2024 at 09:48 PM |
Nairaland Forum / Science/Technology / Programming / [Code Review Help] Explanation In Java Needed (924 Views)
[Code Review Help] Laravel Experts Please HELP! / Question On Regular Expressions In Java / Network Programming In Java (UDP And TCP) (2) (3) (4)
[Code Review Help] Explanation In Java Needed by paranorman(m): 1:21pm On Oct 11, 2019 |
A semi-colon delimited file exists, I just wanna output its content to the console after splitting it like this using PHP: try { The above code works as expected Java's output of this code is funny: import java.io.*; } output: (1) Your name is jacob zuma zoomzoom This java code works just fine, as expected: import java.io.* ; output: (1) First name: john; last name: doe; other names: wick The text file is (output.txt) john;doe;wick question: Why is the console output of the first java program omitting the odd rows of the text file?! NL smileys are getting in the way, so I had to space some characters oddly out. |
Re: [Code Review Help] Explanation In Java Needed by spoilerx: 5:30pm On Oct 11, 2019 |
what is the content of the output.txt file |
Re: [Code Review Help] Explanation In Java Needed by paranorman(m): 7:40pm On Oct 11, 2019 |
spoilerx:I typed it out in my post above, in the "in text file is" session. |
Re: [Code Review Help] Explanation In Java Needed by leoaso(m): 12:28pm On Oct 12, 2019 |
This is the part causing problems.
paranorman:After calling hasNextLine you should only call nextLine once. If you call it twice, it will read a line, and then read another line, which discards the first one you read. The solution is to call nextLine once inside the loop and store it in a variable. Then use that variable instead of calling nextLine repeatedly before the loop body has repeated. 3 Likes 2 Shares |
(1) (Reply)
What are the Advantages Of Javascript Framework Over Vanilla Javascript / My Future Is At Stake! Expert Advice Needed / Job Openings
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15 |