由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 新手请教怎样在Java里读文本文件中的内容
相关主题
JAVA文本文件读写问题请教问题,怎么确定空行!
Re: Need Emergent help for Java I/O!请问同时执行几个bat文件的问题
Java的中文读写问题随机读一个大文件中的任意一行
请教读取中文文件的问题问一个blocking IO的程序
从文件读入数据得到的是bytes新手求教 BufferedReader.readLine()
[合集] Java read/write binary floating point data files?大量文本数据的读取
怎么从键盘输入整数或float?在一个文本文件后面添加行怎么做?
[转载] smtp server in java?Applet读取加密的文件一个问题
相关话题的讨论汇总
话题: java话题: 文本文件话题: use
进入Java版参与讨论
1 (共1页)
c**y
发帖数: 127
1
比如
一行里是
1 3 -1
如果我要读到这个行的每个数,最方便的
操作是怎样。
还有,要输出到文本文件时如何规定格式之类的。
在c++ 里,俺一般用
sscanf,sprintf.
谢谢。
xt
发帖数: 17532
2

Read line, then use StringTokenizer.
You can use OutputStream.print() I think.

【在 c**y 的大作中提到】
: 比如
: 一行里是
: 1 3 -1
: 如果我要读到这个行的每个数,最方便的
: 操作是怎样。
: 还有,要输出到文本文件时如何规定格式之类的。
: 在c++ 里,俺一般用
: sscanf,sprintf.
: 谢谢。

c**g
发帖数: 274
3
The way java does this is kind of complicated (actually
it is similar to c++ way with std io), you open a file
with an FileInputStream, then wrap the FileInputStream with
InputStreamReader to become a Reader, then wrap the
InputStreamReader to become a BufferedReader, then
use readLine(), finally parse out. Kao.

【在 c**y 的大作中提到】
: 比如
: 一行里是
: 1 3 -1
: 如果我要读到这个行的每个数,最方便的
: 操作是怎样。
: 还有,要输出到文本文件时如何规定格式之类的。
: 在c++ 里,俺一般用
: sscanf,sprintf.
: 谢谢。

c******s
发帖数: 8
4
in Java 5.0 (was called 1.5.0 before) you can use scanf/printf same as in c

【在 c**g 的大作中提到】
: The way java does this is kind of complicated (actually
: it is similar to c++ way with std io), you open a file
: with an FileInputStream, then wrap the FileInputStream with
: InputStreamReader to become a Reader, then wrap the
: InputStreamReader to become a BufferedReader, then
: use readLine(), finally parse out. Kao.

w*r
发帖数: 2421
5
ft.... you guys are really die-hard C junkie!!!

【在 c******s 的大作中提到】
: in Java 5.0 (was called 1.5.0 before) you can use scanf/printf same as in c
c**y
发帖数: 127
6
3x

【在 c**g 的大作中提到】
: The way java does this is kind of complicated (actually
: it is similar to c++ way with std io), you open a file
: with an FileInputStream, then wrap the FileInputStream with
: InputStreamReader to become a Reader, then wrap the
: InputStreamReader to become a BufferedReader, then
: use readLine(), finally parse out. Kao.

c**g
发帖数: 274
7
Actually I do appreciate the elegent (or elephant?) way of Java io
to read a file after couples of year java coding. But it does look
so stupid for first time user, hehe.

【在 w*r 的大作中提到】
: ft.... you guys are really die-hard C junkie!!!
w*r
发帖数: 2421
8
their IO interface is very elegent, clear-cut and highly flexible.

【在 c**g 的大作中提到】
: Actually I do appreciate the elegent (or elephant?) way of Java io
: to read a file after couples of year java coding. But it does look
: so stupid for first time user, hehe.

m******t
发帖数: 2416
9

FileReader would lend a little convenience here.

【在 c**g 的大作中提到】
: The way java does this is kind of complicated (actually
: it is similar to c++ way with std io), you open a file
: with an FileInputStream, then wrap the FileInputStream with
: InputStreamReader to become a Reader, then wrap the
: InputStreamReader to become a BufferedReader, then
: use readLine(), finally parse out. Kao.

1 (共1页)
进入Java版参与讨论
相关主题
Applet读取加密的文件一个问题从文件读入数据得到的是bytes
读文件时,如何才能只将空白符当成分隔符?[合集] Java read/write binary floating point data files?
Java练习题 4怎么从键盘输入整数或float?
File generated by Java cannot be read by Android App[转载] smtp server in java?
JAVA文本文件读写问题请教问题,怎么确定空行!
Re: Need Emergent help for Java I/O!请问同时执行几个bat文件的问题
Java的中文读写问题随机读一个大文件中的任意一行
请教读取中文文件的问题问一个blocking IO的程序
相关话题的讨论汇总
话题: java话题: 文本文件话题: use