字符串写入文件
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(); } } } | |
![]() | ![]() |