When is “java.io.IOException:Connection reset by peer” thrown?

java.io.IOException: Connection reset by peer The other side has abruptly aborted the connection in midst of a transaction. That can have many causes which are not controllable from the server side on. E.g. the enduser decided to shutdown the client or change the server abruptly while still interacting with your server, or the client program … Read more

Does close ever throw an IOException?

I have found two cases: Losing the network connection when there is still data in the buffer to be flushed. Having the file system fill up (or reaching your user limit for file size) when there is still data in the buffer to be flushed. Both of those examples depend on something happening while there … Read more

How to check if IOException is Not-Enough-Disk-Space-Exception type?

You need to check the HResult and test against ERROR_DISK_FULL (0x70) and ERROR_HANDLE_DISK_FULL (0x27), which can be converted to HResults by OR‘ing with 0x80070000. For .Net Framework 4.5 and above, you can use the Exception.HResult property: static bool IsDiskFull(Exception ex) { const int HR_ERROR_HANDLE_DISK_FULL = unchecked((int)0x80070027); const int HR_ERROR_DISK_FULL = unchecked((int)0x80070070); return ex.HResult == HR_ERROR_HANDLE_DISK_FULL … Read more

Wait for file to be freed by process

A function like this will do it: public static bool IsFileReady(string filename) { // If the file can be opened for exclusive access it means that the file // is no longer locked by another process. try { using (FileStream inputStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None)) return inputStream.Length > 0; } catch (Exception) { return … Read more

java.io.IOException : No authentication challenges found

This error happens because the server sends a 401 (Unauthorized) but does not give a WWW-Authenticate header which is a hint to the client what to do next. The WWW-Authenticate header tells the client, which kind of authentication is needed (either Basic or Digest). This is probably not very useful in headless http clients, but … Read more

java.io.IOException: mark/reset not supported

The documentation for AudioSystem.getAudioInputStream(InputStream) says: The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream’s read pointer to its original position. … Read more

Error message “unreported exception java.io.IOException; must be caught or declared to be thrown” [duplicate]

void showfile() throws java.io.IOException <—– Your showfile() method throws IOException, so whenever you use it you have to either catch that exception or again thorw it. Something like: try { showfile(); } catch(IOException e) { e.printStackTrace(); } You should learn about exceptions in Java.