当前位置: 首页>>代码示例>>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;未经允许,请勿转载。