Handling connection problems HttpsURLConnection

view story

http://stackoverflow.com – I have a simple client - server app that downloads files thru a REST API. As I use basic http auth the files are sent via ssl. //my download loop HttpsURLConnection conn; //some handling of response codes and content-length InputStream s = conn.getInputStream(); while (true) { i = br.read(buffer); //if server shuts down, I stall here if (i == -1) break; downloadedSize += i; fis.write(buffer, 0, i); } This all works fine and without issues until the code encounters a situation where the server shuts down a file transfer. At that time the code (HowTos)