📄 checktest.java
字号:
import java.io.*;
import java.util.zip.*;
public class checkTest
{
public static void main(String[] args) throws IOException
{
Adler32 inChecker = new Adler32();
Adler32 outChecker = new Adler32();
CheckedInputStream in = null;
CheckedOutputStream out = null;
try
{
//在文件流的基础上建立CheckedStream
//Adler32在构造方法中作为参数被引用
in = new CheckedInputStream(
new FileInputStream("beChecked.txt"),
inChecker);
out = new CheckedOutputStream(
new FileOutputStream("outChecked.txt"),
outChecker);
}
catch (FileNotFoundException e)
{
System.err.println("checkTest: " + e);
System.exit(-1);
}
catch (IOException e)
{
System.err.println("checkTest: " + e);
System.exit(-1);
}
int c;
while ((c = in.read()) != -1)
out.write(c);
System.out.println("Input stream check sum: " +
inChecker.getValue());
System.out.println("Output stream check sum: " +
outChecker.getValue());
in.close();
out.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -