Reputation: 13108
I would like to achieve the following:
BufferedInputStream is = new BufferedInputStream(System.in);
int c = 0;
while((c=is.read())!=-1)
Files.copy(is, path3, StandardCopyOption.REPLACE_EXISTING);
Hoewver it gets stuck in waiting System.in forever.. Any workaround for that?
Thanks in advance.
Upvotes: 0
Views: 256
Reputation: 18712
If you are trying to stop reading on new line or carriage return or end of stream, you may try-
do {
try {
c = is.read();
// Do something
} catch (IOException e) {
e.printStackTrace();
}
} while ((c != -1) & (c != '\n') & (c != '\r'));
Upvotes: 1