本文整理了Java中net.roboconf.core.utils.Utils.copyStreamUnsafelyUseWithCaution()
方法的一些代码示例,展示了Utils.copyStreamUnsafelyUseWithCaution()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.copyStreamUnsafelyUseWithCaution()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:copyStreamUnsafelyUseWithCaution
[英]Copies the content from in into os.
Neither in nor os are closed by this method.
They must be explicitly closed after this method is called.
Be careful, this method should be avoided when possible. It was responsible for memory leaks. See #489.
[中]将内容从中复制到操作系统中。
in和os都不能用这种方法关闭。
调用此方法后,它们必须显式关闭。
小心,如果可能的话,应该避免使用这种方法。它对内存泄漏负有责任。见#489。
代码示例来源:origin: roboconf/roboconf-platform
/**
* Copies the content from in into os.
* <p>
* This method closes the input stream.
* <i>os</i> does not need to be closed.
* </p>
*
* @param in an input stream (not null)
* @param os an output stream (not null)
* @throws IOException if an error occurred
*/
public static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ) throws IOException {
try {
copyStreamUnsafelyUseWithCaution( in, os );
} finally {
in.close();
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Copies the content from inputFile into an output stream.
*
* @param inputFile an input file (must be a file and exist)
* @param os the output stream
* @throws IOException if something went wrong
*/
public static void copyStream( File inputFile, OutputStream os ) throws IOException {
InputStream is = new FileInputStream( inputFile );
try {
copyStreamUnsafelyUseWithCaution( is, os );
} finally {
is.close();
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Copies the content from in into outputFile.
* <p>
* <i>in</i> is not closed by this method.<br>
* It must be explicitly closed after this method is called.
* </p>
*
* @param in an input stream (not null)
* @param outputFile will be created if it does not exist
* @throws IOException if the file could not be created
*/
public static void copyStream( InputStream in, File outputFile ) throws IOException {
OutputStream os = new FileOutputStream( outputFile );
try {
copyStreamUnsafelyUseWithCaution( in, os );
} finally {
os.close ();
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Creates a ZIP file from the map.
* @param entryToContent a map (key = ZIP entry, value = entry content, null for a directory)
* @param targetZipFile
*/
public static void createZipFile( Map<String,String> entryToContent, File targetZipFile ) throws IOException {
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream( new FileOutputStream( targetZipFile ));
for( Map.Entry<String,String> entry : entryToContent.entrySet()) {
zos.putNextEntry( new ZipEntry( entry.getKey()));
if( entry.getValue() != null ) {
ByteArrayInputStream is = new ByteArrayInputStream( entry.getValue().getBytes( "UTF-8" ));
try {
Utils.copyStreamUnsafelyUseWithCaution( is, zos );
} finally {
Utils.closeQuietly( is );
}
}
zos.closeEntry();
}
} finally {
Utils.closeQuietly( zos );
}
}
内容来源于网络,如有侵权,请联系作者删除!