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

     

  • 相关阅读:
    Python安装appium 遇见的报错
    appium
    QQ邮箱/微信邮箱发送邮件
    Python-变量
    神秘的咒语
    宿命的PSS
    E. Congruence Equation
    D. Substring
    leetcode 761. Special Binary String
    F
  • 原文地址:https://www.cnblogs.com/zhangkaiz/p/11032172.html
Copyright © 2020-2023  润新知