如何从文件读固定格式的数据,像在C中一样.急!在线...............

sethyhm 2004-05-03 10:57:25
我要从一个文件中的每一行读一些数据,然后呢,这些行中的数据以空格或者TAB分隔,数据可以是int,float,double,char的混和,JAVA中有这样已经写好的函数吗????
...全文
46 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ac669 2004-05-04
  • 打赏
  • 举报
回复
java.io
Class DataInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--java.io.DataInputStream

All Implemented Interfaces:
DataInput



int read(byte[] b)
Reads some number of bytes from the contained input stream and stores them into the buffer array b.
int read(byte[] b, int off, int len)
Reads up to len bytes of data from the contained input stream into an array of bytes.
boolean readBoolean()
See the general contract of the readBoolean method of DataInput.
byte readByte()
See the general contract of the readByte method of DataInput.
char readChar()
See the general contract of the readChar method of DataInput.
double readDouble()
See the general contract of the readDouble method of DataInput.
float readFloat()
See the general contract of the readFloat method of DataInput.
void readFully(byte[] b)
See the general contract of the readFully method of DataInput.
void readFully(byte[] b, int off, int len)
See the general contract of the readFully method of DataInput.
int readInt()
See the general contract of the readInt method of DataInput.


...
dogcai 2004-05-04
  • 打赏
  • 举报
回复
当然你所使用的这个文档也要用相应的输入流操纵。。
dogcai 2004-05-04
  • 打赏
  • 举报
回复
楼主可以用ObjectFileWriter或者DataOutputStream。。这两种类里面提供不同得数据写入和写出的功能。。你看一下帮助文档就明白我的意思了。。
sean_gao 2004-05-03
  • 打赏
  • 举报
回复
RandomAccessFile?

62,622

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧