Java/Scala Strange behaviour of readline -


i got strange , urgent problem. hope can me. trying read result of command executing. code never reaches println-statement. "hanging up" program, if end of output reached. no failure , no exception. please me. fall despair.

my project mix of scala , java. doesnt matter in language solution is. tried in both. encoding of project cp1252.

here code

var filescript = runtime.getruntime().exec(pathofscript) var isr:inputstreamreader  = new inputstreamreader(filescript.getinputstream()) var in = new bufferedreader(isr) var line:string = "" try {   while ({line = in.readline();  line!= null}) {     println("line: "+line)   }   println("outside !!!");   in.close(); } 

that's strange... java version works fine:

        inputstreamreader isr = new inputstreamreader(new fileinputstream("c:\\anyfile"));         bufferedreader in = new bufferedreader(isr);         string line = "";         try {           while ((line = in.readline()) != null) {             system.out.println("line: "+line);           }           system.out.println("outside !!!");           in.close();         } catch (exception ex) {             ex.printstacktrace();         } 

i think problem in filescript: if gives stream , doesn't close it, you'll never null in while loop. check part. try regular file (like did in example). if works, problem surely in filescript object.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -