简体   繁体   中英

how to read the string from file using RandomAccessFile?

my file content contains four columns

001 mike 1122 98
002 stephen 1232 97

Using RandomAccessFile i need to store the each column in its respective array types.

readInt() is used to read Integer of column 1

how can i read the strings(column 2) to store in string array?

what about using readline

http://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html#readLine()

and then using a tokenizer to identify you cells

http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html

and then populating your arrays ?

(in that case the RandomAccessFile is probably overkill)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM