當前位置: 首頁>>代碼示例>>Java>>正文


Java IOUtils.copyLarge方法代碼示例

本文整理匯總了Java中org.apache.commons.io.IOUtils.copyLarge方法的典型用法代碼示例。如果您正苦於以下問題:Java IOUtils.copyLarge方法的具體用法?Java IOUtils.copyLarge怎麽用?Java IOUtils.copyLarge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.IOUtils的用法示例。


在下文中一共展示了IOUtils.copyLarge方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: put

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void put(LocalResource source, URI destination) throws IOException {
    File target = getFile(destination);
    if (!target.canWrite()) {
        target.delete();
    } // if target is writable, the copy will overwrite it without requiring a delete
    GFileUtils.mkdirs(target.getParentFile());

    InputStream input = source.open();
    try {
        FileOutputStream output = new FileOutputStream(target);
        try {
            IOUtils.copyLarge(input, output);
        } finally {
            output.close();
        }
    } finally {
        input.close();
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:21,代碼來源:FileResourceConnector.java

示例2: downloadFile

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private File downloadFile(HttpResponse response) {
    File dir = new File("downloadedFiles");
    if (!dir.exists()) {
        dir.mkdir();
    }
    File outputFile = new File("downloadedFiles/temp" + RandomStringUtils.randomAlphanumeric(3));
    try {

        IOUtils.copyLarge(response.getEntity().getContent(), new FileOutputStream(outputFile));
        return outputFile;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        request.releaseConnection();
    }
}
 
開發者ID:orshachar,項目名稱:known-issue,代碼行數:17,代碼來源:ExecutableMethodBuilder.java

示例3: generateBinaryDataResponse

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private Response generateBinaryDataResponse(JobId jobId, Optional<BinaryData> maybeBinaryData) {
    if (maybeBinaryData.isPresent()) {
        final BinaryData binaryData = maybeBinaryData.get();

        final StreamingOutput body = outputStream -> {
            IOUtils.copyLarge(binaryData.getData(), outputStream);
            binaryData.getData().close();
        };

        final Response.ResponseBuilder b =
                Response.ok(body, binaryData.getMimeType())
                        .header("Content-Length", binaryData.getSizeOf());

        if (binaryData.getSizeOf() > Constants.MAX_JOB_OUTPUT_SIZE_IN_BYTES_BEFORE_DISABLING_COMPRESSION)
            b.header("Content-Encoding", "identity");

        return b.build();
    } else {
        return Response.status(404).build();
    }
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:22,代碼來源:JobResource.java

示例4: fileUpload

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public String fileUpload(final ResourceType type,
		final String currentFolder, final String fileName,
		final InputStream inputStream)
		throws InvalidCurrentFolderException, WriteException {
	String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
			.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
	File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
	File currentDir = new File(typeDir, currentFolder);
	if (!currentDir.exists() || !currentDir.isDirectory())
		throw new InvalidCurrentFolderException();

	File newFile = new File(currentDir, fileName);
	File fileToSave = UtilsFile.getUniqueFile(newFile.getAbsoluteFile());

	try {
		IOUtils.copyLarge(inputStream, new FileOutputStream(fileToSave));
	} catch (IOException e) {
		throw new WriteException();
	}
	return fileToSave.getName();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:AbstractLocalFileSystemConnector.java

示例5: testFindLargeUpload

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Test
public void testFindLargeUpload() throws Exception {
    final B2Session session = new B2Session(
            new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
                    )));
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path file = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final StatusOutputStream<VersionId> out = new B2LargeUploadWriteFeature(session).write(file, new TransferStatus(), new DisabledConnectionCallback());
    IOUtils.copyLarge(new ByteArrayInputStream(RandomUtils.nextBytes(100)), out);
    out.close();
    assertTrue(new DefaultFindFeature(session).find(file));
    session.close();
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:18,代碼來源:DefaultFindFeatureTest.java

示例6: download

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void download(TomtomCountry country, MetalinkUrl component) {
    for (int i = 0; i < 3; i++) {
        try {
            HttpGet get = new HttpGet(component.getUrl());
            File countryDirectory = directories.get(country.getLabel());

            File downloaded = new File(countryDirectory, component.getName());
            try (InputStream content = client.execute(get).getEntity().getContent(); FileOutputStream fos = new FileOutputStream(downloaded)) {
                IOUtils.copyLarge(content, fos);
            }
            ShapefileExtractor.decompress(countryDirectory, downloaded, country.isOuterworld(), component.getType());
            downloaded.delete();
            return;
        }
        catch (IOException | ExecutionException ex) {
            log.error("Retrying.. ", ex);
        }
    }
    throw new RuntimeException("Too many retry");
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:21,代碼來源:ShapefileDownloader.java

示例7: download

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public Metalink download() throws IOException {
    HttpGet metalinkRequest = new HttpGet(
            "https://edelivery-ad.tomtom.com/automaticdownload/filter/token/" + getToken() + "/product/*/region/*/country/*/release/" + tomtomVersion + "/format/*/output/metalink/file/*");

    File outputFile = new File(outputDirectory + "/Europe." + now().toString(forPattern("ddMMyyyy-HHmm")) + ".metalink");

    log.info("Fetching metalink in path={}", outputFile.getAbsolutePath());

    try (InputStream content = client.execute(metalinkRequest).getEntity().getContent();
        FileOutputStream fos = new FileOutputStream(outputFile)) {
        IOUtils.copyLarge(content, fos);
    }
    log.info("Success!");

    return MetalinkParser.parse(new FileInputStream(outputFile));
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:17,代碼來源:MetalinkDownloader.java

示例8: writeTo

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void writeTo(OutputStream output) {
    try {
        InputStream input = openStream();
        try {
            IOUtils.copyLarge(input, output);
        } finally {
            input.close();
        }
    } catch (Exception e) {
        throw ResourceExceptions.getFailed(getURI(), e);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:13,代碼來源:AbstractExternalResource.java

示例9: execute

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public Object execute(InputStream inputStream, ExternalResourceMetaData metaData) throws IOException {
    this.metaData = metaData;
    FileOutputStream outputStream = new FileOutputStream(destination);
    try {
        IOUtils.copyLarge(inputStream, outputStream);
    } finally {
        outputStream.close();
    }
    return null;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:12,代碼來源:DefaultCacheAwareExternalResourceAccessor.java

示例10: writeTo

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void writeTo(OutputStream outstream) throws IOException {
    InputStream content = getContent();
    try {
        IOUtils.copyLarge(content, outstream);
    } finally {
        IOUtils.closeQuietly(content);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:RepeatableInputStreamEntity.java

示例11: copyTo

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
public void copyTo(OutputStream output) {
    try {
        InputStream inputStream = open();
        try {
            IOUtils.copyLarge(inputStream, output);
        } finally {
            inputStream.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:13,代碼來源:AbstractFileTreeElement.java

示例12: writeIdentityEntity

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
@Override
public void writeIdentityEntity(final InputStream inputStream, final OutputStream outputStream, final long length)
        throws IOException {

    checkNotNull(inputStream, "inputStream");
    checkNotNull(outputStream, "outputStream");
    checkNotNegative(length, "length");

    IOUtils.copyLarge(inputStream, outputStream, 0, length);

}
 
開發者ID:galop-proxy,項目名稱:galop,代碼行數:12,代碼來源:MessageBodyWriterImpl.java

示例13: writeJobOutputToDisk

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private void writeJobOutputToDisk(JobOutput jobOutput, Path outputPath) {
    try {
        IOUtils.copyLarge(jobOutput.getData().getData(), new FileOutputStream(outputPath.toFile(), false));
        jobOutput.getData().getData().close();
    } catch (IOException ex) {
        throw new RuntimeException(outputPath + ": cannot write: " + ex);
    }
}
 
開發者ID:adamkewley,項目名稱:jobson,代碼行數:9,代碼來源:FilesystemJobsDAO.java

示例14: handleChunk

import org.apache.commons.io.IOUtils; //導入方法依賴的package包/類
private boolean handleChunk(final InputStream inputStream, final OutputStream outputStream) throws IOException {

        long chunkSize = readChunkSize(inputStream, outputStream);
        boolean lastChunk = chunkSize == 0;

        if (!lastChunk) {
            // Copy chunk data and the following CRLF.
            IOUtils.copyLarge(inputStream, outputStream, 0, chunkSize + 2);
        }

        return lastChunk;

    }
 
開發者ID:galop-proxy,項目名稱:galop,代碼行數:14,代碼來源:MessageBodyWriterImpl.java


注:本文中的org.apache.commons.io.IOUtils.copyLarge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。