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