赞
踩
package Java10; import java.io.*; import java.nio.charset.StandardCharsets; //字节流:输入流(FileInputStream):读,输出流(FileOutputStream):写 public class InputOutputStream { public static void main(String[] args) throws Exception { //FileInputStream:读文件 InputStream is = null; try { is = new FileInputStream("D:/java/test1/src/a.txt"); byte[] b = is.readAllBytes(); String s = new String(b); System.out.println(s); } catch (IOException e) { e.printStackTrace(); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { e.printStackTrace(); } } //FileOutputStream:写文件 OutputStream o = new FileOutputStream("D:/java/test1/src/a.txt"); byte[] b1 = "hello,晓晓".getBytes(StandardCharsets.UTF_8); o.write(b1); o.close(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。