java - How to renitialize Default Console I/O Stream -


is possible reopen standard console i/o streams during execution after closing them?

public static void main(string[] args) throws ioexception {         system.out.println("hello world!!!");         system.out.println("1:" + system.in.read());         system.out.println("" + filedescriptor.in.valid());       //true         system.in.close();         system.out.println("" + filedescriptor.in.valid());       //false         system.out.println("2:" + system.in.read());              //ioexception         system.in.close(); } 

from this post figure out private static native void setin0(inputstream in); native function used initialize final i/o streams in private static void initializesystemclass() private method after thread initialization.

can renitialize i/o streams?

edit:

as system.in final object cannot modify things like

 system.in=new inputstream() {                  @override                 public int read() throws ioexception {                     throw new unsupportedoperationexception("not supported yet."); //to change body of generated methods, choose tools | templates.                 }             } 

during runtime...
expecting solution through native methods/function retrieve console' handle

there no way reopen arbitrary stream after close it.

that being said, can use system.setin use inputstream stdin. bytearrayinputstream.close doesn't anything, , create own inputstream cannot closed.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -