728x90
반응형
입력
package Ex01;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
public class BufferOutEx {
public static void main(String[] args) throws Exception{
BufferedOutputStream bs=null;
bs=new BufferedOutputStream(new FileOutputStream("bs.txt"));
String str="자바의 입출력을 향상시키는 버퍼의 기능";
bs.write(str.getBytes());
bs.close();
}
}
출력
package Ex01;
import java.io.FileInputStream;
public class BufferInEx {
public static void main(String[] args) throws Exception {
// 바이트 단위로 파읽 읽기
String filePath = "bs.txt";
FileInputStream fileStream = null;
fileStream = new FileInputStream(filePath);
//향상을 위한 버퍼 선언
byte[] readBuffer = new byte[fileStream.available()];
while(fileStream.read(readBuffer)!=-1) {
System.out.print(new String(readBuffer));
}
fileStream.close();
}
}
728x90
반응형
'JAVA > 예제' 카테고리의 다른 글
[JAVA] JComboBox 콤보박스 클릭 시 이미지 출력 (0) | 2022.10.25 |
---|---|
[JAVA] JRadioButton 버튼 클릭시 문구변경 (0) | 2022.10.25 |
[JAVA] swing을 사용한 txt파일 저장 (0) | 2022.10.25 |
[JAVA] 전화번호북 (0) | 2022.10.11 |
[JAVA] 일정관리 프로그램 (0) | 2022.10.11 |
댓글