goback add

字符串写入文件

3515 点击·0 回帖
灯火互联
楼主


package com.zhangry.interview.java;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class WriteFile {

    public static void main(String[] args) {
        try {
            FileOutputStream out = new FileOutputStream("C:\\FileName.txt");
            out.write("字符串写入文件".getBytes());
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
package com.zhangry.interview.java;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFile {
    public static void main(String[] args) {
        try {
            FileOutputStream out = new FileOutputStream("C:\\FileName.txt");
            out.write("字符串写入文件".getBytes());
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


喜欢0 评分0