void init() throws IOException {
String filePath = “…/…/…/desktop/test/1.txt”;
FileOutputStream fos = new FileOutputStream(filePath,true);
try {
byte[] b =new byte[] {
99,100,101,102,103,104,105,106,107,108
};
//fos.write(b); //文件写入
fos.write(50);
fos.write(‘a’);
FileInputStream fis = new FileInputStream(filePath);
System.out.print(fis.read());//文件读出
System.out.print((char)fis.read());
System.out.print(fis.read());
System.out.print((char)fis.read());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
fos.close();
}
}