文件输出字节流(OutputStream)

2018-05-23  本文已影响5人  Joy_yang17
public class OutputByStream {
    public static void main(String[] args) {

        try {
            FileOutputStream fos = new FileOutputStream("learn3.txt");
            String string = new String("我爱高等数学英语Java");
            byte b[] = string.getBytes("UTF-8");
            fos.write(b);
            fos.close();
        
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
上一篇 下一篇

猜你喜欢

热点阅读