//如果该文件不存在,则直接创建,如果存在,则删除后创建
FileOutputStream out=new FileOutputStream("H:\\Lhc\\diary.txt",true);
out.write('A');//写出了A字符的低8位
out.write('B');//写出B字符的低8位
int a=10;//write只能写低8位,那么写一个整数需要写四次,每次8位
out.write(a>>>24);
out.write(a>>>16);
out.write(a>>>8);
out.write(a);
byte[] gbk="水田".getBytes("gbk");
out.write(gbk);
out.close();
IOUtil.printHex("H:\\Lhc\\diary.txt");
public static void copyFile(File srcFile,File destFile) throws IOException{
if(!srcFile.exists()){
throw new FileNotFoundException("未找到源文件");
}
if(!srcFile.isFile()){
throw new IllegalArgumentException(srcFile+"不是文件!");
}
FileInputStream in=new FileInputStream(srcFile);
FileOutputStream out=new FileOutputStream(destFile);
byte[] buf=new byte[8*1024];
int b;
while ((b=in.read(buf,0,buf.length))!=-1){
out.write(buf,0,b);
out.flush();//
}
in.close();
out.close();
}