//个人觉得这样也可以,不一定要使用RandomAccessFile来读取,现在许多人好象都喜欢这样,但完全可以使用其它流
try
{
DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream("Test.java")));
while(input.available() != 0)
{
long a = input.readLong();
//你希望的操作。。
}
}
catch (EOFException e)
{
System.out.println("It has reached the end of this file!");
}
catch (IOException e)
{
System.out.println("IOException");
}
//以上代码编译通过,没有测试过,呵呵,希望对你有参考价值
try
{
DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream("Test.java")));
while(input.available() != 0)
{
long a = input.readLong();
//你希望的操作。。
}
}
catch (EOFException e)
{
System.out.println("It has reached the end of this file!");
}
catch (IOException e)
{
System.out.println("IOException");
}
//以上代码编译通过,没有测试过,呵呵,希望对你有参考价值
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货