java - InputStream.read() blocking (jamming) execution -


i've been writing basic bit level encryption code, , i'm pretty sure algorithm correct.. can't test it. when run code, first loop (using system.in.read() ) jams code. when send eof signal via terminal, code progresses no further - i've checked primitive print statements on next line.

as understand, sending eof should have read() return -1, exiting loop.

what missing?

thank you.

public class bitlevel {  public static void main(string[] args) throws exception {     fileinputstream input = new fileinputstream(args[0]);     fileoutputstream output = new fileoutputstream(args[1]);     arraylist<integer> key = new arraylist<integer>();     int = 0;     system.out.print("enter key: ");     system.out.flush();     int c = system.in.read();     while (c != -1) {         key.add((integer) c);         c = system.in.read();     }     c = input.read();     while (c != -1) {         output.write(c ^ key.get(i).intvalue());         output.flush();         i++;         = % key.size();     } } 

}

the loop never end because "c" doesn't changed inside of it. think meant call c = input.read(); inside loop, @ end.

also, btw, should close streams after done them.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -