G*********a 发帖数: 1080 | 1 it's really wired, i have a file of strings, and has methods such as
getString(int), getInt(String)... it worked fine before but today it keeps
throwing this error: java.io.EOFException
at java.io.RandomAccessFile.readInt(RandomAccessFile.java:705)
i didn't change any code of that part, and the file could be read into and
printout well, all the other String works fine, except. one is "persian"...
anyone knows the possible reason?
Thanks! |
G*********a 发帖数: 1080 | 2 found the error only happened on the last String of the saved file when using
getString(int no)... still can't finger out yet... //thinking...
【在 G*********a 的大作中提到】 : it's really wired, i have a file of strings, and has methods such as : getString(int), getInt(String)... it worked fine before but today it keeps : throwing this error: java.io.EOFException : at java.io.RandomAccessFile.readInt(RandomAccessFile.java:705) : i didn't change any code of that part, and the file could be read into and : printout well, all the other String works fine, except. one is "persian"... : anyone knows the possible reason? : Thanks!
|
m******t 发帖数: 2416 | 3 Looks like you are trying to use readInt to read a string "persian".
See the javadoc.
【在 G*********a 的大作中提到】 : found the error only happened on the last String of the saved file when using : getString(int no)... still can't finger out yet... //thinking...
|
G*********a 发帖数: 1080 | 4 no, every string has a id, it should find the string according to the given
id, the id is integer.
using
keeps
and
"persian"...
【在 m******t 的大作中提到】 : Looks like you are trying to use readInt to read a string "persian". : See the javadoc.
|
g*****g 发帖数: 34805 | 5 You'd better provide the piece of readInt(String) code
and the format of your text file, or nobody can help
you out. To me you are trying to read beyond EOF.
【在 G*********a 的大作中提到】 : no, every string has a id, it should find the string according to the given : id, the id is integer. : : using : keeps : and : "persian"...
|
G*********a 发帖数: 1080 | 6 thanks! bug corrected! it's the binary search algorithm doesn't work properly,
it read one string length over the end of the file.
Thanks everyone!
goodbug, u r cool!
given
【在 g*****g 的大作中提到】 : You'd better provide the piece of readInt(String) code : and the format of your text file, or nobody can help : you out. To me you are trying to read beyond EOF.
|
B******N 发帖数: 445 | 7 why not use java Properties?
properly,
【在 G*********a 的大作中提到】 : thanks! bug corrected! it's the binary search algorithm doesn't work properly, : it read one string length over the end of the file. : Thanks everyone! : goodbug, u r cool! : : given
|
G*********a 发帖数: 1080 | 8 where? and how? @@
【在 B******N 的大作中提到】 : why not use java Properties? : : properly,
|
B******N 发帖数: 445 | 9 i read your post it's like you have a property file:
propty file format should be like this
key=value
if it's the file format, using java.util.Properties API will be very easy. If
not then it's different story.
the
"persian".
【在 G*********a 的大作中提到】 : where? and how? @@
|