当前位置: 首页>>代码示例>>Java>>正文


Java IOUtil.transfer方法代码示例

本文整理汇总了Java中org.databene.commons.IOUtil.transfer方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtil.transfer方法的具体用法?Java IOUtil.transfer怎么用?Java IOUtil.transfer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.databene.commons.IOUtil的用法示例。


在下文中一共展示了IOUtil.transfer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeBinaryFile

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
/** Creates a binary file and writes to it all content provided by the source {@link InputStream}.
 * @param filePath the path of the file to save
 * @param source an {@link InputStream} which provides the content to write to the file
 * @param overwrite flag which indicates if an existing file may be overwritten by the operation
 * @return true if a formerly existing file was overwritten.
 * @throws FunctionalFailure if a file was already present and overwriting was disabled. */
@Override
public boolean writeBinaryFile(String filePath, InputStream source, boolean overwrite) {
    assertWritingPermitted("writeBinaryFile()");
    File.verifyFilePath(filePath);
    OutputStream out = null;
    try {
        FileObject target = getFileObject(filePath);
        boolean existedBefore = checkWritable(target, overwrite); // NOSONAR
        out = target.getContent().getOutputStream();
        IOUtil.transfer(source, out);
        logger.debug("Wrote binary file {}", filePath);
        return existedBefore;
    }
    catch (IOException e) {
        throw new TechnicalException("Error writing text file", e);
    }
    finally {
        IOUtil.close(out);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:27,代码来源:FileInteractionImpl.java

示例2: readBinaryFile

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
/** Reads a binary file and provides its content as an array of bytes. */
@Override
public byte[] readBinaryFile(String filePath) {
    File.verifyFilePath(filePath);
    if (!exists(filePath) || isDirectory(filePath)) {
        throw new AutomationException("No file exists at the given file path");
    }

    InputStream in = null;
    try {
        in = getInputStreamForFile(filePath);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        IOUtil.transfer(in, out);
        logger.debug("Binary file read: {}", filePath);
        return out.toByteArray();
    }
    catch (IOException e) {
        throw new TechnicalException("Error reading binary file", e);
    }
    finally {
        IOUtil.close(in);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:24,代码来源:FileInteractionImpl.java

示例3: redirectTo

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public void redirectTo(OutputStream out) throws IOException {
    if (!bufferedTextAvailable()) {
        if (process.isRunning()) {
            // expect process output
            waitUntilAvailable();
        }
        else if (!availableWithinResponseTimeout()) {
            // perform another check if process output was pending
            // (necessary for Windows)
            return;
        }
    }
    InputStream bufferStream;
    synchronized (buffer) {
        bufferStream = new ByteArrayInputStream(this.buffer.getBytes(), this.pos, this.buffer.length() - this.pos);
    }
    IOUtil.transfer(bufferStream, out);
    out.flush();
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:20,代码来源:InputStreamWatchDog.java

示例4: saveStreamContent

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void saveStreamContent(InputStream in, File tempFile) throws FileNotFoundException, IOException {
    tempFile.getParentFile().mkdirs();
    FileOutputStream out = null;
    try {
        out = new FileOutputStream(tempFile);
        IOUtil.transfer(in, out);
    }
    finally {
        IOUtil.close(out);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:12,代码来源:FileFieldImpl.java

示例5: redirectStdInFrom

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public void redirectStdInFrom(String processType, String processName, int processId, InputStream in) {
    try {
        ProcessWrapper process = getProcess(processId);
        OutputStream stdIn = process.getStdIn();
        IOUtil.transfer(in, stdIn);
        stdIn.flush();
    }
    catch (IOException e) {
        throw new TechnicalException("Error redirecting stdout", e);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:13,代码来源:CommandLineActionImpl.java

示例6: getContentOfURI

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public static String getContentOfURI(String uri, String encoding) throws IOException {
    Reader reader = IOUtil.getReaderForURI(uri, encoding);
    StringWriter writer = new StringWriter();
    IOUtil.transfer(reader, writer);
    IOUtil.close(reader);
    IOUtil.close(writer);
    return writer.toString();
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:9,代码来源:GitClientIntegrationTest.java

示例7: runFromCommandLine

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void runFromCommandLine(String file, String database, String stage) throws IOException, InterruptedException {
    String command = "benerator -Ddatabase=" + database + " -Dstage=" + stage + " " + file;
    logger.debug(command);
    Process process = Runtime.getRuntime().exec(command);
    IOUtil.transfer(process.getInputStream(), System.out);
    process.waitFor();
    logger.debug(String.valueOf(process.exitValue()));
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:9,代码来源:ShopDBTest.java

示例8: copySchemaTo

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void copySchemaTo(File targetFolder) throws IOException, FileNotFoundException {
String xmlSchemaPath = BeneratorFactory.getSchemaPathForCurrentVersion();
   URL schemaUrl = getClass().getClassLoader().getResource(xmlSchemaPath);
   if (schemaUrl == null)
   	throw new FileNotFoundException("File not found: " + xmlSchemaPath);
InputStream in = schemaUrl.openStream();
File file = new File(targetFolder, xmlSchemaPath.substring(xmlSchemaPath.lastIndexOf('/')));
OutputStream out = new FileOutputStream(file);
IOUtil.transfer(in, out);
in.close();
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:12,代码来源:Archetype.java


注:本文中的org.databene.commons.IOUtil.transfer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。