block « API « Java I/O Q&A





1. java inputstream read blocking    stackoverflow.com

According to the java api, the InputStream.read() is described as:

If no byte is available because the end of the stream has been reached, the value -1 is ...

2. why does java's inputstream.close() block?    stackoverflow.com

My Java program uses ProcessBuilder (with redirectErrorStream set true) and has a loop that runs the processes's inputstream's read method, which is blocking. The external program I'm calling then comes to ...

3. Java IO inputstream blocks while reading standard output & standard error of an external C program    stackoverflow.com

I've posted the same question here a few days ago(http://stackoverflow.com/questions/1088941/java-reading-standard-output-from-an-external-program-using-inputstream), and I found some excellent advices in dealing with a block in while reading ( while(is.read()) != -1)), but I ...

4. java: datainputstream: do read calls take up processor time while waiting for data?    stackoverflow.com

If I call read() on a DataInputStream, will it take up CPU cycles waiting for data or does it yield the current thread and get woken up by an interrupt signaling ...

5. Java serialization, ObjectInputStream.readObject(), check if will block    stackoverflow.com

I'm using an ObjectInputStream to call readObject for reading in serialized Objects. I would like to avoid having this method block, so I'm looking to use something like Inputstream.available(). InputStream.available() will tell ...

6. how to read using InputStreamReader without blocking    stackoverflow.com

Is there a simple way to turn the standard code:

in = new InputStreamReader(socket.getInputStream());
String message = "";
while ((size = in.read(buf)) != -1){
    message += new String(buf, 0, size);
}
so ...

7. Pipe transfer blocks when writing object with small pipe size    stackoverflow.com

I'm having a bit of problem with an example I'm currently testing. For some reason, the execution blocks when writing at oos.writeObject(new SimpleObject());, despite that fact that the pipe should transfer ...

8. How do I/O operations block?    stackoverflow.com

I am specifically referring to InputStream (Java SE) and its implementations. How is blocking performed? I'm a little worried that they use a "busy-waiting" mechanism, as it would produce a ...

9. Piped Stream Issue in Freemarker    stackoverflow.com

I need to load and process a template in freemarker. I am using a piped stream to read back the generated result by freemarker. Sample code:

PipedInputStream pi = new PipedInputStream();
PipedOutputStream po ...





10. Why is the FileInputStream read() not blocking?    stackoverflow.com

I've got a Writer program that writes one line of text to a file, then waits until the user hits return before it writes another line and then exits. Only after ...

11. What does InputStream.available() do in Java?    stackoverflow.com

What does InputStream.available() do in Java? I read the documentation, but I still cannot make it out. The doc says:

Returns the number of bytes that can be read (or skipped ...

12. Java code style for open stream try/finally block    stackoverflow.com

This is a code style question. I notice much example code including some examples from Oracle ensure that a stream is closed in the following manner:

InputStream in = ...

13. Always blocking input stream for testing?    stackoverflow.com

I'm doing some unit tests where essentially I need the input stream to block forever. Right now I'm using this to construct the input stream

InputStream in = new ByteArrayInputStream("".getBytes());
While it works ...

14. Java DataInputStream.read() causing 20% constant CPU usage while being blocked.    stackoverflow.com

I have a server-side application opens a socket thread for each connected client. I have a DataInputStream in each thread, which calls read(byte[]array) to read data. I also set the socket ...

15. Java InputStream.read(byte[], int, int) method, how to block until the exact number of bytes has been read    stackoverflow.com

I'm writing a simple client/server network application that sends and receives fixed size messages through a TCP socket. So far, I've been using the getInputStream() and getOutputStream() methods of the Socket class ...

16. java try finally block to close stream    stackoverflow.com

I want to close my stream in the finally block, but it throws an IOException so it seems like I have to nest another try block in my finally block in ...





17. CipherInputStream could not reach last block in java    stackoverflow.com

I'm using CipherInputStream for decrypting an CipherOutputStream. It works but it could not get the last block. What should I do? Here is my codes: receiver:

CipherInputStream csin = new CipherInputStream(in,mit.outCipher);
     ...

18. readLine() blocking    coderanch.com

19. Does readInt() in DataInputStream class block?    coderanch.com

For the readFully() method in DataInputStream class, I know the method will block until a certain criteria occurs like below This method blocks until one of the following conditions occurs: b.length bytes of input data are available, in which case a normal return is made. End of file is detected, in which case an EOFException is thrown. An I/O error occurs, ...

20. InputStreams read() extended blocking    coderanch.com

My conclusion to the problem I'm having, which follows, is that InputStreams read() method blocks for a lot longer than it has to when its waiting for something to read. So if that sounds right I guess you dont have to read what follows, and hopefully you can tell me how to shorten this time or suggest a workaround. As in ...

21. Does FileReader block/ lock the file    coderanch.com

22. InputStream read() blocking    coderanch.com

For a particular customer, our applet is sometimes failing to connect to our servlet. The applet gets to the inputStream.read(); line and just blocks - seemingly waiting for the first byte of data that never comes. I am using standard applet and servlet connection code (applet POSTs a text/plain String in UTF8 and the servlet returns a text/plain String in UTF8). ...

23. writing to file via fileChannel in 4kb blocks to match disk sectors perfectly.    coderanch.com

Hi I am writing some data to a file via a fileChannel and I want to make sure that it fits neatly on the disk block size so the disk does not end up doing the read,copy, write routine to fill sectors that are only half used. I am writing 4KB blocks which are the same size as the disks 4096 ...

24. Question about System.in, FileoutputStream and blocking    forums.oracle.com

I have written a simple java program that read the System.in and append it to file (which is the first argument of the program). Here is the context: my client launch several instance of this program at the same time, with the same file passed in argument. In a first time, I did not use the FileChannel.lock() method because I didn't ...

26. BufferedReader block behaviour    forums.oracle.com

I am calling a method from various places in the main program that will extract a String from a BufferedReader. However if this extracted String contains a certain substring (in this case the word "ticker") i want to silently discard the String and block until the next incoming String is received. The String containing ticker is merely sent to keep the ...

27. Txt file read in- StringTokenizer- Try Block Catch for errors    forums.oracle.com

This is an example of a good field from the text file XYG726;Smith,Mr. John M.;29.96;comedy;101008;100604 Not so good line Lu15;Will, Mark;50.00;Science;030305;030807 The file should then be printed out in the program not to a text file. It only needs to print the invoice number and error code letter assignment. If you have any questions feel free to let me know. Thanks ...