📄 randomreadtest.java
字号:
import java.io.*;
public class RandomReadTest
{
public static void main(String args[])
{
try
{
FileInputStream fs_in = new FileInputStream("sample.dat");
DataInputStream in = new DataInputStream(fs_in);
double sum = 0.0;
int count = 0;
try
{
while (true)
{
sum += in.readDouble();
count++;
}
}
catch (EOFException eofe)
{
System.out.println("Counted: " + count);
System.out.println("Average: " + (sum / count));
}
in.close();
}
catch (FileNotFoundException fe)
{
System.err.println(fe);
}
catch (IOException ioe)
{
System.out.println(ioe);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -