本文整理了Java中org.eclipse.equinox.internal.p2.core.helpers.FileUtils.copyStream()
方法的一些代码示例,展示了FileUtils.copyStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyStream()
方法的具体详情如下:
包路径:org.eclipse.equinox.internal.p2.core.helpers.FileUtils
类名称:FileUtils
方法名:copyStream
[英]Copy an input stream to an output stream. Optionally close the streams when done. Return the number of bytes written.
[中]将输入流复制到输出流。完成后可选择关闭流。返回写入的字节数。
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.artifact.repository
protected void performProcessing() throws IOException {
File resultFile = null;
try {
resultFile = process();
// now write the processed content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
} else {
setStatus(new Status(IStatus.ERROR, Activator.ID, "Unpacking fails because intermediate file is empty: " + resultFile)); //$NON-NLS-1$
}
} finally {
if (resultFile != null)
resultFile.delete();
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core
public static void copy(File source, File destination, File root, boolean overwrite) throws IOException {
File sourceFile = new File(source, root.getPath());
if (!sourceFile.exists())
throw new FileNotFoundException("Source: " + sourceFile + " does not exist"); //$NON-NLS-1$//$NON-NLS-2$
File destinationFile = new File(destination, root.getPath());
if (destinationFile.exists())
if (overwrite)
deleteAll(destinationFile);
else
throw new IOException("Destination: " + destinationFile + " already exists"); //$NON-NLS-1$//$NON-NLS-2$
if (sourceFile.isDirectory()) {
destinationFile.mkdirs();
File[] list = sourceFile.listFiles();
for (int i = 0; i < list.length; i++)
copy(source, destination, new File(root, list[i].getName()), false);
} else {
destinationFile.getParentFile().mkdirs();
try (InputStream in = new BufferedInputStream(new FileInputStream(sourceFile)); OutputStream out = new BufferedOutputStream(new FileOutputStream(destinationFile));) {
copyStream(in, false, out, false);
}
}
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core
copyStream(in, false, new FileOutputStream(outFile), true);
} catch (FileNotFoundException e) {
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.artifact.repository
protected void performProcessing() throws IOException {
File resultFile = null;
try {
resultFile = process();
// now write the processed content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
} else {
setStatus(new Status(IStatus.ERROR, Activator.ID, "Unpacking fails because intermediate file is empty: " + resultFile)); //$NON-NLS-1$
}
} finally {
if (resultFile != null)
resultFile.delete();
}
}
代码示例来源:origin: org.eclipse.equinox.p2.artifact/repository
protected void performProcessing() throws IOException {
File resultFile = null;
try {
resultFile = process();
// now write the processed content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
} else {
setStatus(new Status(IStatus.ERROR, Activator.ID, "Unpacking fails because intermediate file is empty: " + resultFile)); //$NON-NLS-1$
}
} finally {
if (resultFile != null)
resultFile.delete();
}
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core
in = new BufferedInputStream(new FileInputStream(sourceFile));
out = new BufferedOutputStream(new FileOutputStream(destinationFile));
copyStream(in, false, out, false);
} finally {
try {
代码示例来源:origin: org.eclipse.equinox.p2/core
in = new BufferedInputStream(new FileInputStream(sourceFile));
out = new BufferedOutputStream(new FileOutputStream(destinationFile));
copyStream(in, false, out, false);
} finally {
try {
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.artifact.repository
private void verify() throws IOException {
BufferedInputStream resultStream = null;
try {
if (tempStream == null)
// no one wrote to this stream so there is nothing to pass on
return;
// Ok, so there is content, close the tempStream
tempStream.close();
setStatus(verifyContent());
// now write the content to the final destination
resultStream = new BufferedInputStream(new FileInputStream(inputFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
resultStream = null;
} finally {
if (inputFile != null)
inputFile.delete();
if (resultStream != null)
resultStream.close();
}
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.artifact.repository
private void verify() throws IOException {
BufferedInputStream resultStream = null;
try {
if (tempStream == null)
// no one wrote to this stream so there is nothing to pass on
return;
// Ok, so there is content, close the tempStream
tempStream.close();
setStatus(verifyContent());
// now write the content to the final destination
resultStream = new BufferedInputStream(new FileInputStream(inputFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
resultStream = null;
} finally {
if (inputFile != null)
inputFile.delete();
if (resultStream != null)
resultStream.close();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core
in = new BufferedInputStream(new FileInputStream(sourceFile));
out = new BufferedOutputStream(new FileOutputStream(destinationFile));
copyStream(in, false, out, false);
} finally {
try {
代码示例来源:origin: org.eclipse.equinox.p2.artifact/repository
private void verify() throws IOException {
BufferedInputStream resultStream = null;
try {
if (tempStream == null)
// hmmm, no one wrote to this stream so there is nothing to pass on
return;
// Ok, so there is content, close the tempStream
tempStream.close();
setStatus(verifyContent());
// now write the content to the final destination
resultStream = new BufferedInputStream(new FileInputStream(inputFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
resultStream = null;
} finally {
if (inputFile != null)
inputFile.delete();
if (resultStream != null)
resultStream.close();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.artifact.repository
private void verify() throws IOException {
BufferedInputStream resultStream = null;
try {
if (tempStream == null)
// no one wrote to this stream so there is nothing to pass on
return;
// Ok, so there is content, close the tempStream
tempStream.close();
setStatus(verifyContent());
// now write the content to the final destination
resultStream = new BufferedInputStream(new FileInputStream(inputFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
resultStream = null;
} finally {
if (inputFile != null)
inputFile.delete();
if (resultStream != null)
resultStream.close();
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.artifact.repository
@Override
protected void performProcessing() throws IOException {
File resultFile = null;
try {
resultFile = process();
// now write the processed content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, getDestination(), false);
} else {
setStatus(new Status(IStatus.ERROR, Activator.ID, MirrorRequest.ARTIFACT_PROCESSING_ERROR, "Unpacking fails because intermediate file is empty: " + resultFile, null)); //$NON-NLS-1$
}
} catch (IOException e) {
setStatus(new Status(IStatus.ERROR, Activator.ID, MirrorRequest.ARTIFACT_PROCESSING_ERROR, "Unpacking fails", e)); //$NON-NLS-1$
throw e;
} finally {
if (resultFile != null)
resultFile.delete();
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core
private static File[] untarFile(File source, File outputDir) throws IOException, TarException {
List<File> untarredFiles = new ArrayList<>();
try (TarFile tarFile = new TarFile(source)) {
for (Enumeration<TarEntry> e = tarFile.entries(); e.hasMoreElements();) {
TarEntry entry = e.nextElement();
try (InputStream input = tarFile.getInputStream(entry)) {
File outFile = createSubPathFile(outputDir, entry.getName());
outFile = outFile.getCanonicalFile(); //bug 266844
untarredFiles.add(outFile);
if (entry.getFileType() == TarEntry.DIRECTORY) {
outFile.mkdirs();
} else {
if (outFile.exists())
outFile.delete();
else
outFile.getParentFile().mkdirs();
try {
copyStream(input, false, new FileOutputStream(outFile), true);
} catch (FileNotFoundException e1) {
// TEMP: ignore this for now in case we're trying to replace
// a running eclipse.exe
}
outFile.setLastModified(entry.getTime());
}
}
}
}
return untarredFiles.toArray(new File[untarredFiles.size()]);
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.core
outFile.getParentFile().mkdirs();
try {
copyStream(input, false, new FileOutputStream(outFile), true);
} catch (FileNotFoundException e1) {
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core
zipEntry.setTime(source.lastModified());
output.putNextEntry(zipEntry);
copyStream(input, true, output, false);
} catch (ZipException ze) {
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.core
outFile.getParentFile().mkdirs();
try {
copyStream(input, false, new FileOutputStream(outFile), true);
} catch (FileNotFoundException e1) {
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.core
zipEntry.setTime(source.lastModified());
output.putNextEntry(zipEntry);
copyStream(input, true, output, false);
} catch (ZipException ze) {
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.publisher
return;
output = new BufferedOutputStream(output);
FileUtils.copyStream(new BufferedInputStream(new FileInputStream(inclusion)), true, output, true);
} catch (ProvisionException e) {
LogHelper.log(e.getStatus());
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.publisher
return;
output = new BufferedOutputStream(output);
FileUtils.copyStream(new BufferedInputStream(new FileInputStream(inclusion)), true, output, true);
} catch (ProvisionException e) {
LogHelper.log(e.getStatus());
内容来源于网络,如有侵权,请联系作者删除!