IO流

I/O

 

import java.io.FileInputStream;
import java.io.FileOutputStream;
public class File {
public static void main(String[] args) {
String file = new String ("data.txt");
try {


FileOutputStream out = new FileOutputStream(file);
byte str[] = "12345abcdef@#%&*软件工程".getBytes();
out.write(str);
out.close();
}catch(Exception e) {
e.printStackTrace();
}
try {
FileInputStream in = new FileInputStream(file);
byte yhl[] = new byte[1024];
int mr = in.read(yhl);


System.out.println("文件是: "+new String(yhl,0,mr));
in.close();

}

catch (Exception e) {
e.printStackTrace();
}
}
}

posted @ 2019-07-05 21:36  盘少  阅读(82)  评论(0编辑  收藏  举报