JAVA IO - 포맷 출력 흐름
917 단어 printstream
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
public class PrintStreamTest {
public static void main(String args[]) {
try {
OutputStream out = new FileOutputStream("helloworld.txt");
PrintStream ps = new PrintStream(out);
ps.printf("This is my %s Test", "PrintStream");
ps.close();
InputStream in = new FileInputStream("helloworld.txt");
byte[] bs = new byte[1024];
int len = -1;
if((len = in.read(bs)) != -1){
System.out.println(new String(bs, 0, len));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}