Reassigns standard input stream (System.in) from a file
Reassigns standard input stream (System.in) from a file
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class SystemExample {
public static void main(String[] args) throws IOException {
InputStream in = new FileInputStream(new File("c:\\temp\\out.log"));
System.setIn(in);
byte b[] = new byte[System.in.available()];
System.in.read(b);
System.out.println(new String(b));
}
}
Tags: java.lang, java.lang.System, System, System examples
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply