@IgnoreJRERequirement // Should only be invoked on Java 8+ or Android API 24+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
public static long getContentLength(HttpURLConnection connection) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return connection.getContentLengthLong(); } try { long length = Long.parseLong(connection.getHeaderField("Content-Length")); if (length >= 0) return length; } catch (Exception err) { // nothing to do } return -1; } }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
@Override public Path call() throws IOException { Path folder = target.getParent(); String prefix = target.getFileName().toString(); Path tempModuleLocation = Files.createTempFile(folder, prefix + "_", ".tmp"); tempModuleLocation.toFile().deleteOnExit(); logger.debug("Downloading {} from {}", target, url); long length = -1; URLConnection conn = url.openConnection(); if (conn instanceof HttpURLConnection) { length = ((HttpURLConnection) conn).getContentLengthLong(); } try (InputStream is = url.openStream(); OutputStream os = Files.newOutputStream(tempModuleLocation)) { copy(is, os, length, listener); Files.move(tempModuleLocation, target, StandardCopyOption.REPLACE_EXISTING); } return target; }
long contentLengthLong = httpConn.getContentLengthLong(); long lastModified = httpConn.getLastModified(); LOGGER.log(Level.INFO, "Reading " + (contentLengthLong < 0L
@Override public long contentLength() { return connection.getContentLengthLong(); } @Override
/** * Returns the value of the content-length header field as long * * @return the content-length of the resource */ long getContentLengthLong() { return delegateUrlConnexion.getContentLengthLong(); }
@Override public long contentLength() { return connection.getContentLengthLong(); }
/** * Returns the value of "Content-Length" response header. * * <pre><code>Content-Length: 49</code></pre> * * @return the value of "Content-Length" response header or -1 if the content length is not known. */ @Override public long length() { HttpURLConnection con = this._connection; if (con == null) return -1; return con.getContentLengthLong(); }
@Override public long getContentLengthLong() { return super.getContentLengthLong(); }
protected static long getFileSize(URL url) throws Exception { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); long length = conn.getContentLengthLong(); conn.disconnect(); return length; }
private long checkHead(String cveUrl) { try { URL url = new URL(cveUrl); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("HEAD"); connection.connect(); connection.getInputStream(); return connection.getContentLengthLong(); } catch (IOException e) { System.out.println("Failed to determine content length"); } return 0; }
@IgnoreJRERequirement // Should only be invoked on Java 8+ or Android API 24+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
private Long getFileWeightRemote(String urlFileRemote) throws IOException, InterruptedException { URL url = new URL(urlFileRemote); HttpURLConnection conn = DeployApp.buildHttpUrlConnection(url); return conn.getContentLengthLong(); }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
private void validateUpload(File file, String remotePathRelative) throws IOException, InterruptedException { if (file.isFile() && this.validateUpdate) { String urlFile = String.format("%1$s/files/%2$s/%3$s", this.urlApp, this.newVersion, remotePathRelative); URL url = new URL(urlFile); HttpURLConnection conn = buildHttpUrlConnection(url); Long weightRemote = conn.getContentLengthLong(); Long weight = file.length(); if (!weight.equals(weightRemote)) { throw new IOException("In validate upload file to FTP, file in server not equal length to file local"); } conn.disconnect(); } }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }
@IgnoreJRERequirement // Should only be invoked on Java 7+. @Override public long getContentLengthLong() { return delegate.getContentLengthLong(); }