當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。