@Override public boolean exists() throws IOException { HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (IOException e) { // This is what we are testing for, so its not really an exception return false; } finally { if (con != null) con.disconnect(); } }
@Override public boolean exists() throws IOException { HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (IOException e) { // This is what we are testing for, so its not really an exception return false; } finally { if (con != null) con.disconnect(); } }
public boolean exists() throws IOException{ HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (IOException e) { // This is what we are testing for, so its not really an exception return false; } finally { if (con != null) con.disconnect(); } }
public HTTPHelper(URL url) { this.url = url; proxy = null; try { URLConnection conn = openConnection(); conn.setDefaultUseCaches(false); } catch (IOException e) { e.printStackTrace(); } }
@Override public InputStream openInputStream() throws IOException { HttpURLConnection connection = openConnection(); return new WrapperInputStream(connection, connection.getInputStream()); }
public HTTPHelper(URL url) { this.url = url; proxy = null; try { URLConnection conn = openConnection(); conn.setDefaultUseCaches(false); } catch (IOException e) { e.printStackTrace(); } }
public HTTPHelper(URL url) { this.url = url; proxy = null; try { URLConnection conn = openConnection(); conn.setDefaultUseCaches(false); } catch (IOException e) { e.printStackTrace(); } }
@Override public InputStream openInputStream() throws IOException { HttpURLConnection connection = openConnection(); return new WrapperInputStream(connection, connection.getInputStream()); }
public InputStream openInputStream() throws IOException { HttpURLConnection connection = openConnection(); return new WrapperInputStream(connection, connection.getInputStream()); }
/** * Open an input stream for the requested byte range. Its the client's responsibility to close the stream. * * @param start start of range in bytes * @param end end of range ni bytes * @return * @throws IOException */ public InputStream openInputStreamForRange(long start, long end) throws IOException { HttpURLConnection connection = openConnection(); String byteRange = "bytes=" + start + "-" + end; connection.setRequestProperty("Range", byteRange); return new WrapperInputStream(connection, connection.getInputStream()); }
/** * @return content length of the resource * @throws IOException */ @Override public long getContentLength() throws IOException { HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); if ((con.getResponseCode() != HttpURLConnection.HTTP_OK)) { System.out.println("Error (" + con.getResponseMessage() + " ) fetching content length: " + url); return -1; } else { String contentLength = con.getHeaderField("Content-Length"); return contentLength == null ? -1 : Long.parseLong(contentLength); } } finally { if (con != null) con.disconnect(); } }
/** * @return content length of the resource * @throws IOException */ public long getContentLength() throws IOException { HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); if((con.getResponseCode() != HttpURLConnection.HTTP_OK)) { System.out.println("Error (" + con.getResponseMessage() + " ) fetching content length: " + url); return -1; } else { String contentLength = con.getHeaderField("Content-Length"); return contentLength == null ? -1 : Long.parseLong(contentLength); } } finally { if (con != null) con.disconnect(); } }
/** * @return content length of the resource * @throws IOException */ @Override public long getContentLength() throws IOException { HttpURLConnection con = null; try { con = openConnection(); con.setRequestMethod("HEAD"); if ((con.getResponseCode() != HttpURLConnection.HTTP_OK)) { System.out.println("Error (" + con.getResponseMessage() + " ) fetching content length: " + url); return -1; } else { String contentLength = con.getHeaderField("Content-Length"); return contentLength == null ? -1 : Long.parseLong(contentLength); } } finally { if (con != null) con.disconnect(); } }
/** * Open an input stream for the requested byte range. Its the client's responsibility to close the stream. * * @param start start of range in bytes * @param end end of range ni bytes * @return * @throws IOException * * @deprecated since 12/10/14 Will be removed in a future release, as is somewhat fragile * and not used. */ @Override @Deprecated public InputStream openInputStreamForRange(long start, long end) throws IOException { HttpURLConnection connection = openConnection(); String byteRange = "bytes=" + start + "-" + end; connection.setRequestProperty("Range", byteRange); return new WrapperInputStream(connection, connection.getInputStream()); }
/** * Open an input stream for the requested byte range. Its the client's responsibility to close the stream. * * @param start start of range in bytes * @param end end of range ni bytes * @return * @throws IOException * * @deprecated since 12/10/14 Will be removed in a future release, as is somewhat fragile * and not used. */ @Override @Deprecated public InputStream openInputStreamForRange(long start, long end) throws IOException { HttpURLConnection connection = openConnection(); String byteRange = "bytes=" + start + "-" + end; connection.setRequestProperty("Range", byteRange); return new WrapperInputStream(connection, connection.getInputStream()); }