Redian新闻
>
ERROR!java.io.RandomAccessFile.readInt
avatar
ERROR!java.io.RandomAccessFile.readInt# Java - 爪哇娇娃
G*a
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!
avatar
G*a
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!

avatar
m*t
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...

avatar
G*a
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.

avatar
g*g
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"...

avatar
G*a
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.

avatar
B*N
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

avatar
G*a
8
where? and how? @@

【在 B******N 的大作中提到】
: why not use java Properties?
:
: properly,

avatar
B*N
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? @@
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。