Redian新闻
>
java可以直接去读txt file里指定的一行吗?
avatar
java可以直接去读txt file里指定的一行吗?# Java - 爪哇娇娃
l*s
1
msdn可以下载了
avatar
b*n
2
请问
java 里可以直接去读 txt file 里指定的第 n 行
而不经过读入前 n-1 行吗?
谢谢
avatar
l*s
3
看了一下,community version和professional没什么差别了呀,主要少了个code pen.
不错

【在 l*s 的大作中提到】
: msdn可以下载了
avatar
s*n
4
no...

【在 b*********n 的大作中提到】
: 请问
: java 里可以直接去读 txt file 里指定的第 n 行
: 而不经过读入前 n-1 行吗?
: 谢谢

avatar
l*s
5
msdn可以下载了
avatar
S*a
6
no way. u might be able to skip, but java still needs to read to skip

【在 b*********n 的大作中提到】
: 请问
: java 里可以直接去读 txt file 里指定的第 n 行
: 而不经过读入前 n-1 行吗?
: 谢谢

avatar
l*s
7
看了一下,community version和professional没什么差别了呀,主要少了个code pen.
不错

【在 l*s 的大作中提到】
: msdn可以下载了
avatar
g*g
8
There's no line concept in a file. Line is
determined by line separator. So you have to read
every character to know if this is a new line.
You can't do this in any language.
You can however, skip certain bytes without reading.

【在 b*********n 的大作中提到】
: 请问
: java 里可以直接去读 txt file 里指定的第 n 行
: 而不经过读入前 n-1 行吗?
: 谢谢

avatar
k*n
9
还不错。。写typescript 很好。
avatar
A*o
10
不可以跳过,但是可以用buffer reader去读。

【在 b*********n 的大作中提到】
: 请问
: java 里可以直接去读 txt file 里指定的第 n 行
: 而不经过读入前 n-1 行吗?
: 谢谢

avatar
k*n
11
还不错。。写typescript 很好。
avatar
b*n
12
Thanks.
So which means, without knowing how many bytes are ahead of the n line,
there's no way for you to directly read the n line?
one more question,
let's say if I know there are m bytes ahead of the n line,
and try to skip,
does that mean the time consumed in reading the previous m bytes can be
skipped as well?
Thanks!

【在 g*****g 的大作中提到】
: There's no line concept in a file. Line is
: determined by line separator. So you have to read
: every character to know if this is a new line.
: You can't do this in any language.
: You can however, skip certain bytes without reading.

avatar
t*e
13
Try randomaccessfile. but again, you don't know where is the line untill you
read it.
avatar
g*g
14

right
yes

【在 b*********n 的大作中提到】
: Thanks.
: So which means, without knowing how many bytes are ahead of the n line,
: there's no way for you to directly read the n line?
: one more question,
: let's say if I know there are m bytes ahead of the n line,
: and try to skip,
: does that mean the time consumed in reading the previous m bytes can be
: skipped as well?
: Thanks!

avatar
w*d
15
Java handles input/output using (Data/Object)Input/OutPutStream. So thinks
about I/O as bit stream, Java has to read from the beginning to determine
the content, remember, text files' lines are separated by line separator and
there is no way for Java to know which is the nth line until it reads in
bit by bit.
From the implementation point of view, unless the length of each line is
fixed or header information containing each line's location is stored (plain
text file doesn't have header though),

【在 b*********n 的大作中提到】
: Thanks.
: So which means, without knowing how many bytes are ahead of the n line,
: there's no way for you to directly read the n line?
: one more question,
: let's say if I know there are m bytes ahead of the n line,
: and try to skip,
: does that mean the time consumed in reading the previous m bytes can be
: skipped as well?
: Thanks!

avatar
h*e
16
如果是固定行长度文件,可以直接跳
这东西和JAVA没什么关系把.用C/C++都是一样的弄.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。