Results 21 to 26 of 26
- 06-10-2012, 06:27 PM #21
Re: Problems with loading a comma-seperated value file.
Are there any println statements in the code? Are any of them printing out null?
Have you read the API doc for the method you are using to read the data? What does it say about returning a null value?It shouldn't in any way be reading that null valueIf you don't understand my response, don't ignore it, ask a question.
- 06-10-2012, 06:39 PM #22
Computer Slave
- Join Date
- Jun 2012
- Location
- USA
- Posts
- 17
- Rep Power
- 0
Re: Problems with loading a comma-seperated value file.
Problem resolved: I had to add a blank 8th line to the save files (just CSVFile.write("\n");) and added a reader for the 8th line at the end of the while loop. Hope anyone who has this problem sees this, as it's quite a simple, but really elusive error since it randomly adds a "null" out of absolutely nowhere. Thanks for the help anyway guys! I appreciate it :)
- 06-10-2012, 06:44 PM #23
Re: Problems with loading a comma-seperated value file.
You never explained where the null value was coming from.
AFAIK there is no way to read a null value from a file.
Adding lines to your file hides or ignores the error in your code.If you don't understand my response, don't ignore it, ask a question.
- 06-11-2012, 11:16 AM #24
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Re: Problems with loading a comma-seperated value file.
That is a hack of a fix.
Form the documentation for BufferedReader.readLine() (which you should have read):
"
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.
"
This is what people have been telling you.
You were at the end of the file and reading a null.
You should have been reading in the lines in a loop and exiting when the result of readLine() == null.
Assumign you were working on a fixed format for the file, and so expecting a certain number of lines, then your code was clearly wrong as it was attempting to read an extra line that didn't exist, and so I would be questioning why the code expected an extra line, rather than hacking in a blank line just so it didn't fall over.Please do not ask for code as refusal often offends.
- 06-17-2012, 08:28 AM #25
Computer Slave
- Join Date
- Jun 2012
- Location
- USA
- Posts
- 17
- Rep Power
- 0
Re: Problems with loading a comma-seperated value file.
This is specifically why I gave Furable rep, because after a while I figured out why I was having problems - both because he helped me and because he gave me the solution I didn't pay mind to until I was at wit's end. We all look over simple solutions sometimes right?
Anyway, I was at line 2 out of 7 of the save file. It was giving me a null value before I even reached the third line. readLine() == null if statements would not have worked because it would have read
as the String value rather than just "null" because it had other characters included. The solution entirely evaded me and my stupidity did not permit me to see the answer until - again - I was at wit's end. Again why I gave Furable more than deserved reputation.0,0,100,0,0
nullLast edited by dddJewelsbbb; 06-17-2012 at 08:35 AM.
-
Similar Threads
-
Reading a comma separated file into JTextPane
By arndtmatt in forum New To JavaReplies: 3Last Post: 04-09-2012, 10:08 PM -
MySQLDump to comma dilim text file
By Sobutai in forum New To JavaReplies: 1Last Post: 05-11-2011, 07:39 AM -
Java Regular Expressions: Comma Seperated List
By sgtblitz in forum New To JavaReplies: 3Last Post: 04-18-2011, 09:17 PM -
Delimite the file using comma
By gokulcool in forum New To JavaReplies: 3Last Post: 12-30-2008, 05:40 PM -
How to parse the CSV(Comma separation values)file and validate the file using java
By padmajap13 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 03:46 AM


3Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks