文件输出字节流(OutputStream)

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

}

你可能感兴趣的:(文件输出字节流(OutputStream))