I/O

时间:2019-07-05 14:48:46   收藏:0   阅读:90

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();
}
}
}

原文:https://www.cnblogs.com/q1525551818/p/11137451.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!