---恢复内容开始---
1 import java.io.FileInputStream; 2 import java.io.FileOutputStream; 3 public class file { 4 public static void main(String[] args) { 5 String file = new String ("data.txt"); 6 try { 7 FileOutputStream out = new FileOutputStream(file); 8 byte str[] = "12345abcdef@#%&*软件工程".getBytes(); 9 out.write(str); 10 out.close(); 11 } 12 catch(Exception e) { 13 e.printStackTrace(); 14 } 15 try { 16 FileInputStream in = new FileInputStream(file); 17 byte yhl[] = new byte[1024]; 18 int mr = in.read(yhl); 19 20 System.out.println("文件是: "+new String(yhl,0,mr)); 21 in.close(); 22 23 } 24 25 catch (Exception e) { 26 e.printStackTrace(); 27 } 28 } 29 }
---恢复内容结束---