상세 컨텐츠

본문 제목

[입출력] 지금은 못하겠다 나중에하자

자바

by esoesmio 2023. 4. 10. 21:33

본문

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

public class z13 {


    public static void main(String[] args)   {

        try {
            OutputStream os = new FileOutputStream("/Users/eunsukkim/Desktop/text31.txt");

            byte[] bytearr = new byte[5];
            for(int i=0;i<5;i++){

                bytearr[i] = (byte)(i*5);
            }
            //1 byte 를 1byte씩 출력

            String num1 = "-128";

os.write(bytearr);

            os.write(num1.getBytes());

            os.flush();
            os.close();

        } catch (FileNotFoundException e) {
            System.out.println(e.getMessage());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}

관련글 더보기

댓글 영역