一、字节输入流
FileInputStream fileInputStream=null;
try {
fileInputStream=new FileInputStream(fileUrl);
byte []by=fileInputStream.readAllBytes();
String string=new String(by);
System.out.println(string);
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally {
fileInputStream.close();
}
二、字节输出流
FileOutputStream fileOutputStream=null;
try {
fileOutputStream=new FileOutputStream("C:\\Users\\zhang\\Desktop\\zhang\\a.txt");
String string=new String("ABCDEFG");
byte by[]=string.getBytes();
fileOutputStream.write(by);
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally {
fileOutputStream.close();
}