프로그래밍/JAVA
Input/OutputStream
GANADARA
2018. 7. 19. 21:20
try {
InputStream a = new FileInputStream("C:\\mytext.txt");
byte[] buffer = new byte[BUFFER_SIZE];
while(true){
int i = a.read(buffer);
System.out.println("hi : " + i);
if ( i == -1 ) break;
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
OutputStream a = new FileOutputStream("C:\\mytext.txt") ;
try {
String b = "행복하단. 그런 말을 하고 있었으면서.";
byte[] c = b.getBytes();
a.write(c);
} catch (Exception e) {
}