b*n
2 楼
请问
java 里可以直接去读 txt file 里指定的第 n 行
而不经过读入前 n-1 行吗?
谢谢
java 里可以直接去读 txt file 里指定的第 n 行
而不经过读入前 n-1 行吗?
谢谢
l*s
5 楼
msdn可以下载了
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 行吗?
: 谢谢
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 行吗?
: 谢谢
k*n
9 楼
还不错。。写typescript 很好。
k*n
11 楼
还不错。。写typescript 很好。
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.
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.
t*e
13 楼
Try randomaccessfile. but again, you don't know where is the line untill you
read it.
read it.
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!
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!
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!
h*e
16 楼
如果是固定行长度文件,可以直接跳
这东西和JAVA没什么关系把.用C/C++都是一样的弄.
这东西和JAVA没什么关系把.用C/C++都是一样的弄.
相关阅读
priorityBlockingQueue with fairness?问一个java的面试题 (转载)eclipse remote debug java (tomcat) , has to connect with eclipse for tomcat to start?Front desk IT opening at a top bank免费$500或2次往返机票offer Sapphire Preferred Card一个java servelet 的问题刚准备拣Java打算写个小project各位大拿给推荐一个工具,java转UML学习JAVA的人要注意11款用于优化、分析源代码的Java工具Is MappedByteBuffer.putInt atomic?疯狂的Chase信用卡Bonus, $500现金或$625机票任你选Web Seminar hosted by CINAOUG on 2011/06/13 (转载)现在写代码还有人开着API么?package org.dyno.visual.swing.layouts does not exist大家熟读了Java source code几遍?eclipse java profiler pluginhow to debug SEGV of JVM ?帮忙看下这个是用什么技术做的