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


Java IOUtils.copy方法代碼示例

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


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

示例1: download

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
public static void download(String from, String to) {
	InputStream in = null;
	OutputStream out = null;
	try {
		URL apdf = new URL(from);
		in = apdf.openStream();
		System.out.println("開始下載:" + from);
		out = new FileOutputStream(new File(to));
		IOUtils.copy(in, out);
		out.flush();
		System.out.println("下載完成:" + to);
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		try {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.close();
			}
		} catch (Exception e2) {
			e2.printStackTrace();
		}
	}
}
 
開發者ID:bdceo,項目名稱:bd-codes,代碼行數:27,代碼來源:Download.java

示例2: decompress

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
/**
 * Decompresses the whole of the compressed RTF
 *  stream, outputting the resulting RTF bytes.
 * Note - will decompress any padding at the end of
 *  the input, if present, use {@link #getDeCompressedSize()}
 *  if you need to know how much of the result is
 *  real. (Padding may be up to 7 bytes).
 */
public void decompress(InputStream src, OutputStream res) throws IOException {
   // Validate the header on the front of the RTF
   compressedSize = LittleEndian.readInt(src);
   decompressedSize = LittleEndian.readInt(src);
   int compressionType = LittleEndian.readInt(src);
   int dataCRC = LittleEndian.readInt(src);
   
   // TODO - Handle CRC checking on the output side
   
   // Do we need to do anything?
   if(compressionType == UNCOMPRESSED_SIGNATURE_INT) {
      // Nope, nothing fancy to do
      IOUtils.copy(src, res);
   } else if(compressionType == COMPRESSED_SIGNATURE_INT) {
      // We need to decompress it below
   } else {
      throw new IllegalArgumentException("Invalid compression signature " + compressionType);
   }

   // Have it processed
   super.decompress(src, res);
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:31,代碼來源:CompressedRTF.java

示例3: copyToTempFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private File copyToTempFile(InputStream is) throws IOException {
	String partName = packagePart.getPartName().getName();
	partName = partName.substring(partName.lastIndexOf('/')+1);
	final int idx = partName.lastIndexOf('.');
	final String prefix = ((idx == -1) ? partName : partName.substring(0, idx)) + "-";
	final String suffix = (idx == -1 || idx == partName.length()-1) ? "" : partName.substring(idx);

	final File of = TempFile.createTempFile(prefix, suffix);
	try (FileOutputStream fos = new FileOutputStream(of)) {
		IOUtils.copy(is, fos);
	}
	of.deleteOnExit();
	return of;
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:15,代碼來源:OPCEntry.java

示例4: copyToTempFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private File copyToTempFile(InputStream is) throws IOException {
	final String partName = entry.getName();
	final int idx = partName.lastIndexOf('.');
	final String prefix = ((idx == -1) ? partName : partName.substring(0, idx)) + "-";
	final String suffix = (idx == -1 || idx == partName.length()-1) ? "" : partName.substring(idx);

	final File of = TempFile.createTempFile(prefix, suffix);
	try (FileOutputStream fos = new FileOutputStream(of)) {
		IOUtils.copy(is, fos);
	}
	of.deleteOnExit();
	return of;
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:14,代碼來源:OLEEntry.java

示例5: copyToTempFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private File copyToTempFile(InputStream is) throws IOException {
	final String prefix = "embed-"+embed.getPersistId()+"-";
	final String suffix = ".dat";

	final File of = TempFile.createTempFile(prefix, suffix);
	try (FileOutputStream fos = new FileOutputStream(of)) {
		IOUtils.copy(is, fos);
	}
	of.deleteOnExit();
	return of;
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:12,代碼來源:HSLFOleEmbed.java

示例6: copyToTempFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private File copyToTempFile(InputStream is) throws IOException {
	final String prefix = record.getClass().getSimpleName() + "-";
	final String suffix = ".zip";

	final File of = TempFile.createTempFile(prefix, suffix);
	try (FileOutputStream fos = new FileOutputStream(of)) {
		IOUtils.copy(is, fos);
	}
	of.deleteOnExit();
	return of;
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:12,代碼來源:HSLFEntry.java

示例7: copy

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private void copy(final InputStream input, OutputStream output, long start, long length) throws InterruptedStreamException {
    // Slice the input stream considering offset and length
    try (InputStream in = input) {
        if (length > 0) {
            long skip = in.skip(start);
            if (skip != start) {
                LOGGER.log(Level.WARNING, "Could not skip requested bytes (skipped: " + skip + " on " + start + ")");
            }
            byte[] data = new byte[1024 * 8];
            long remaining = length;
            int nr;
            while (remaining > 0) {
                nr = in.read(data);
                if (nr < 0) {
                    break;
                }
                remaining -= nr;
                output.write(data, 0, nr);
            }
        } else {
            IOUtils.copy(in, output);
        }
    } catch (IOException e) {
        // may be caused by a client side cancel
        LOGGER.log(Level.FINE, "A downloading stream was interrupted.", e);
        throw new InterruptedStreamException();
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:29,代碼來源:BinaryResourceBinaryStreamingOutput.java

示例8: loadLibWin

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private static void loadLibWin(String path, String name) {
    name = name + ".dll";
    try {
        // have to use a stream
        InputStream in = InfrequentBehaviourFilter.class.getResourceAsStream("/" + name);
        // always write to different location
        File fileOut = new File(name);
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
    } catch (Exception e) {
        throw new RuntimeException("Failed to load required DLL", e);
    }
}
 
開發者ID:raffaeleconforti,項目名稱:ResearchCode,代碼行數:16,代碼來源:BenchmarkCommandline.java

示例9: loadLibMac

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private static void loadLibMac(String path, String name) {
    name = name + ".jnilib";
    try {
        // have to use a stream
        InputStream in = InfrequentBehaviourFilter.class.getResourceAsStream("/" + name);
        // always write to different location
        File fileOut = new File(name);
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
    } catch (Exception e) {
        throw new RuntimeException("Failed to load required JNILIB", e);
    }
}
 
開發者ID:raffaeleconforti,項目名稱:ResearchCode,代碼行數:16,代碼來源:BenchmarkCommandline.java

示例10: loadLibLinux

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private static void loadLibLinux(String path, String name) {
    name = name + ".so";
    try {
        // have to use a stream
        InputStream in = InfrequentBehaviourFilter.class.getResourceAsStream("/" + name);
        // always write to different location
        File fileOut = new File(name);
        OutputStream out = FileUtils.openOutputStream(fileOut);
        IOUtils.copy(in, out);
        in.close();
        out.close();
    } catch (Exception e) {
        throw new RuntimeException("Failed to load required SO", e);
    }
}
 
開發者ID:raffaeleconforti,項目名稱:ResearchCode,代碼行數:16,代碼來源:BenchmarkCommandline.java

示例11: printGeneratedDRL

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
/**
 * Converts a decision table into DRL and prints the result in the
 * passed OutputStream.
 *
 * @param decisionTable the decision table to be converted.
 * @param target        the stream where the generated DRL will be printed.
 */
private void printGeneratedDRL( InputStream decisionTable, OutputStream target ) {
    try {
        DecisionTableProviderImpl dtp = new DecisionTableProviderImpl();
        String drl = dtp.loadFromInputStream( decisionTable, null );

        IOUtils.copy( new ByteArrayInputStream( drl.getBytes() ), target );
    } catch ( IOException ex ) {
        throw new IllegalStateException( ex );
    }
}
 
開發者ID:Salaboy,項目名稱:drools-workshop,代碼行數:18,代碼來源:ClinicalRulesJUnitTest.java

示例12: execute

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
@Override
public StreamingResponseBody execute(ExportParameters parameters) {
    final TransformationCacheKey contentKey = getCacheKey(parameters);
    ExportUtils.setExportHeaders(parameters.getExportName(), //
            parameters.getArguments().get(ExportFormat.PREFIX + CSVFormat.ParametersCSV.ENCODING), //
            getFormat(parameters.getExportType()));
    return outputStream -> {
        try (InputStream cachedContent = contentCache.get(contentKey)) {
            IOUtils.copy(cachedContent, outputStream);
        }
    };
}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:13,代碼來源:CachedExportStrategy.java

示例13: toBlob

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
public Blob toBlob(final String name, final File file) {
    FileInputStream fis = null;
    ByteArrayOutputStream baos = null;
    try {
        fis = new FileInputStream(file);
        baos = new ByteArrayOutputStream();
        IOUtils.copy(fis, baos);
        return new Blob(name, ExcelService.XSLX_MIME_TYPE, baos.toByteArray());
    } catch (IOException ex) {
        throw new ExcelService.Exception(ex);
    } finally {
        IOUtils.closeQuietly(fis);
        IOUtils.closeQuietly(baos);
    }
}
 
開發者ID:isisaddons-legacy,項目名稱:isis-module-excel,代碼行數:16,代碼來源:ExcelFileBlobConverter.java

示例14: copyFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private boolean copyFile( String src, String dest ) throws KettleFileException, IOException {
  FileObject srcFile = getFileObjectFromKettleVFS( src );
  FileObject destFile = getFileObjectFromKettleVFS( dest );
  try ( InputStream in = KettleVFS.getInputStream( srcFile );
      OutputStream out = KettleVFS.getOutputStream( destFile, false ) ) {
    IOUtils.copy( in, out );
  }
  return true;
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:10,代碼來源:SharedObjects.java

示例15: loadRamFile

import org.apache.poi.util.IOUtils; //導入方法依賴的package包/類
private FileObject loadRamFile( String filename ) throws Exception {
  String targetUrl = RAMDIR + "/" + filename;
  try ( InputStream source = getFileInputStream( filename ) ) {
    FileObject fileObject = KettleVFS.getFileObject( targetUrl );
    try ( OutputStream targetStream = fileObject.getContent().getOutputStream() ) {
      IOUtils.copy( source, targetStream );
    }
    return fileObject;
  }
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:11,代碼來源:XsdValidatorIntTest.java


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