List of utility methods to do URL Copy
void | copy(URL fromUrl, File toFile) copy InputStream in = null; OutputStream out = null; try { in = fromUrl.openStream(); out = new FileOutputStream(toFile); byte[] bytes = new byte[16384]; while (true) { int bytesRead = in.read(bytes); ... |
void | copy(URL in, File out) copy InputStream is = in.openStream(); OutputStream os = new FileOutputStream(out); byte[] buffer = new byte[4096]; int len; while ((len = is.read(buffer)) != -1) { os.write(buffer, 0, len); os.close(); ... |
void | copy(URL source, String destination) copy the file of a given URL to the given destination InputStream in = null; FileOutputStream out = null; try { in = source.openStream(); out = new FileOutputStream(destination); int c; byte[] buffer = new byte[2048]; int read = in.read(buffer); ... |
void | copy_url_to_file(String url, String filename) copurtfile URL u = new URL(url);
InputStream is = u.openStream();
copy_stream_to_file(is, filename);
|
void | copyFile(URL url, String destFilePath) Copy a file from a URL to a destination file byte[] buffer = new byte[4096]; InputStream inputStream = null; FileOutputStream fileOutputStream = null; try { File destFile = new File(destFilePath); fileOutputStream = new FileOutputStream(destFile); inputStream = url.openStream(); int bytesRead = inputStream.read(buffer); ... |
void | copyFromURL(final String query, final File target) copy data from URL to the target file final URL url = new URL(query); final InputStream in = url.openStream(); final OutputStream fous = new FileOutputStream(target); final byte buff[] = new byte[0x3FF]; int sz = 0; try { while ((sz = in.read(buff)) >= 0) { fous.write(buff, 0, sz); ... |
void | copyRemoteFile(URL url, File localFile) copy Remote File if (url == null || localFile == null) return; if (url.getFile() == "" || url.getFile() == null) return; if (localFile.isDirectory()) { localFile = new File(localFile.getPath() + File.separator + url.getFile()); if (!localFile.exists()) { ... |
void | copyResource(URL from, File to) copy Resource if (from == null) { System.out.printf("Resource could not be copied to: %s%n", to); return; System.out.printf("Copring resource: %s to: %s%n", from, to); try { OutputStream fos = new BufferedOutputStream(new FileOutputStream(to)); InputStream in = new BufferedInputStream(from.openStream()); ... |
void | copyResource(URL resource, File destination) copy Resource if (resource == null) { throw new IllegalArgumentException("URL must not be null."); if (destination == null) { throw new IllegalArgumentException("URL must not be null."); try (InputStream inStream = resource.openStream()) { File parent = destination.getParentFile(); ... |
void | copyUrlBinaryFile(String fileName, String sourceUrlPath, String destPath) This method will open any URL input source and copy the content to local path as binary file try { File temp = new File(destPath + fileName); if (temp.exists()) return; URL url = new URL(sourceUrlPath + fileName); BufferedInputStream bis = new BufferedInputStream(url.openStream(), 10240); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destPath + fileName), 10240); byte[] buffer = new byte[1024]; ... |