IO流
package three;
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class IO { public static void main(String[] args) { File file = new File("data.txt"); System.out.println("路径:"+file.getAbsolutePath()); 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[] str1 = new byte[100]; int length = in.read(str1); System.out.println("文件中的信息是:"+ new String(str1,0,length)); in.close(); }catch(Exception e) { e.printStackTrace(); } } }