代码如下:
package com;
import java.io.*;
public class Example16 {
public static void main(String args[]){
int bytes[]={1,2,3,4,5};
try{
RandomAccessFile raf=new RandomAccessFile("D:\Example9.txt","rw");
for(int i=0;i raf.writeInt(bytes);
}
for(int i=bytes.length-1;i>=0;i--){
raf.seek(i*4);
System.out.println(raf.readInt()); } raf.close(); }catch (IOException e){ e.printStackTrace(); }}}
为什么写入txt文件中不是12345而是几个小方块呢?
|