写出图像为目标文件扩展名对应的格式

@param targetFile 目标文件
@return 是否成功写出，如果返回false表示未找到合适的Writer
@throws IORuntimeException IO异常
163911
public boolean write(File targetFile) throws IORuntimeException {
		final String formatName = FileUtil.extName(targetFile);
		if (StrUtil.isNotBlank(formatName)) {
			this.targetImageType = formatName;
		}
		
		if(targetFile.exists()) {
			targetFile.delete();
		}
		
		ImageOutputStream out = null;
		try {
			out = ImgUtil.getImageOutputStream(targetFile);
			return write(out);
		} finally {
			IoUtil.close(out);
		}
	}
897851
public static File copyFile(String src, String dest, StandardCopyOption... options) throws IORuntimeException {
		Assert.notBlank(src, "Source File path is blank !");
		Assert.notNull(src, "Destination File path is null !");
		return copyFile(Paths.get(src), Paths.get(dest), options).toFile();
	}
977966
public static void copyResourceToFile(String resourceAbsoluteClassPath, File targetFile) throws IOException {
        InputStream is = ResourceUtil.class.getResourceAsStream(resourceAbsoluteClassPath);
        if (is == null) {
            throw new IOException("Resource not found! " + resourceAbsoluteClassPath);
        }
        OutputStream os = null;
        try {
            os = new FileOutputStream(targetFile);
            byte[] buffer = new byte[2048];
            int length;
            while ((length = is.read(buffer)) != -1) {
                os.write(buffer, 0, length);
            }
            os.flush();
        } finally {
            try {
                is.close();
                if (os != null) {
                    os.close();
                }
            } catch (Exception ignore) {
                // ignore
            }
        }
    }
1342659
public static FileUtils.FileCopyResult gunzip(final File pulledFile, File outFile)
  {
    return gunzip(Files.asByteSource(pulledFile), outFile);
  }
613342
public static void writeFile (byte[] bytes, String targetFileName) throws OSHelperException {
		FileOutputStream fos;
		try {
			fos = new FileOutputStream (targetFileName);
		} catch (FileNotFoundException ex) {
			throw new OSHelperException ("Received a FileNotFoundException when trying to open target file " + targetFileName + ".", ex);
		}
		try {
			fos.write (bytes);
		} catch (IOException ex) {
			throw new OSHelperException ("Received an IOException when trying to write to target file " + targetFileName + ".", ex);
		} finally {
			try {
				fos.close ();
			} catch (IOException ex) {
				throw new OSHelperException ("Received an IOException when trying to close FileOutputStream for target file " + targetFileName + ".", ex);
			}
		}
	}
913447
@Override
    public FileBuilder addFile(Path source, Path target) throws IOException
    {
        checkTarget(target);
        FileBuilder fb =  new FileBuilder();
        fb.target = target;
        fb.size = (int) Files.size(source);
        try (FileChannel fc = FileChannel.open(source, READ))
        {
            fb.content = fc.map(FileChannel.MapMode.READ_ONLY, 0, fb.size);
        }
        FileTime fileTime = Files.getLastModifiedTime(source);
        fb.time = (int)fileTime.to(TimeUnit.SECONDS);
        fb.compressFilename();
        fileBuilders.add(fb);
        return fb;
    }
891714
@Override
	public Map<String,byte[]> findScriptResourcesForAgent( String targetId ) throws IOException {

		Map<String,byte[]> result = new HashMap<>( 0 );
		File targetDir = new File( findTargetDirectory( targetId ), Constants.PROJECT_SUB_DIR_SCRIPTS );
		if( targetDir.isDirectory()){

			List<String> exclusionPatterns = Arrays.asList(
				"(?i).*" + Pattern.quote( Constants.LOCAL_RESOURCE_PREFIX ) + ".*"
			);

			result.putAll( Utils.storeDirectoryResourcesAsBytes( targetDir, exclusionPatterns ));
		}

		return result;
	}
1319132
private void writeTargetI18nFile(SlingI18nMap i18nMap, File targetfile, OutputFormat selectedOutputFormat) throws IOException, JSONException {
    if (selectedOutputFormat == OutputFormat.XML) {
      FileUtils.fileWrite(targetfile, CharEncoding.UTF_8, i18nMap.getI18nXmlString());
    }
    else if (selectedOutputFormat == OutputFormat.PROPERTIES) {
      FileUtils.fileWrite(targetfile, CharEncoding.ISO_8859_1, i18nMap.getI18nPropertiesString());
    }
    else {
      FileUtils.fileWrite(targetfile, CharEncoding.UTF_8, i18nMap.getI18nJsonString());
    }
    buildContext.refresh(targetfile);
  }
1295596
public void writeTo(OutputStream target) throws IOException {
        this.data.close();
        BufferedInputStream tempIn = new BufferedInputStream(new FileInputStream(this.tempFile));
        byte[] buffer = new byte[8192];
        int bytesRead = -1;
        while((bytesRead = tempIn.read(buffer)) >= 0) {
            target.write(buffer, 0, bytesRead);
        }
        tempIn.close();
        this.tempFile.delete();
    }
46512
public static boolean coreExpandArchive(String sourcePath, String targetPath) throws IOException {
        ZipArchiveInputStream in = null;
        OutputStream out = null;

        try {

            // make sure we're working with absolute canonical paths
            File source = new File(sourcePath).getCanonicalFile();
            File target = new File(targetPath).getCanonicalFile();

            // open the archive
            in = new ZipArchiveInputStream(getInputStream(source));

            // expand all entries of the archive
            for (ZipArchiveEntry entry = in.getNextZipEntry(); entry != null; entry = in.getNextZipEntry()) {

                // get the pathname of the entry (this will be a relative path)
                String outFilename = entry.getName();

                // construct the absolute path of where this entry will be expanded
                String targetPlusOutFile = target.getPath() + File.separator + outFilename;

                File targetFile = new File(targetPlusOutFile);
                char ending = outFilename.charAt(outFilename.length() - 1);

                if (ending == '/' || ending == '\\') {
                    fileMkDirs(targetFile);
                    if (helper != null) {
                        helper.setPermissions(targetFile, entry.getUnixMode());
                    }
                    continue;
                } else {
                    fileMkDirs(targetFile.getParentFile());
                }

                // expand the entry
                out = getOutputStream(targetFile);
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                }

                // Close the streams
                out.close();

                if (helper != null) {
                    helper.setPermissions(targetFile, entry.getUnixMode());
                }

                out = null;
            }
            in.close();
            in = null;

            return true;

        } catch (IOException e) {
            throw e;
        } finally {
            // try to close any open files
            tryToClose(out);
            tryToClose(in);
        }
    }
926450
public boolean dumpTo(File outFile) throws IOException {
        if (exists()) {
            dump(getOffset(), outFile);
            return true;
        } else {
            return false;
        }
    }
642608
public static void copyFolder(String sourcePath, String targetPath, final String filterName,
         final boolean recursive) throws IOException
   {
      File path = new File(targetPath);
      if (!path.exists())
      {
         if (!path.mkdirs())
            throw new IOException("outdir can't be created");
      }
      File a = new File(sourcePath);
      String[] fileNames = a.list(new FilenameFilter()
      {
         public boolean accept(File dir, String fname)
         {
            if (new File(dir, fname).isDirectory())
            {
               return true;
            }
            else
            {
               return fname.endsWith(filterName);
            }
         }

      });
      File jarFile = null;
      if (fileNames != null)
      {
         for (String fileName : fileNames)
         {
            jarFile = new File(sourcePath + File.separator + fileName);

            if (jarFile.isFile())
            {
               copyFile(jarFile, targetPath);
            }
            if (recursive && jarFile.isDirectory())
            {
               copyFolder(sourcePath + File.separator + fileName, targetPath + File.separator + fileName, filterName,
                     recursive);
            }
         }
      }
   }
997873
@Override
    public FileBuilder addFile(Path source, String target) throws IOException
    {
        checkTarget(target);
        FileBuilder fb = new FileBuilder(target, source);
        fileBuilders.add(fb);
        return fb;
    }
712424
public void NeEvl(String outputPath) throws IOException{


		String res = "";
		res += calcByLength()+"\n";
		res += calcByType()+"\n";
		res += calcByOOV()+"\n";
		res += calcByCOOV()+"\n";
		res += calcByOOV2()+"\n";
		res += calcByOOVRate()+"\n";



		if(outputPath != null ){
			File outFile =new File(outputPath);
			Writer out=new OutputStreamWriter(new FileOutputStream(outFile));
			out.write(res);
			out.close();
		}

	}
960426
static void copyFromWarToFolder(VirtualFile virtualFileOrFolder, File targetFolder) throws IOException {
        if (virtualFileOrFolder.isDirectory() && !virtualFileOrFolder.getName().contains(".")) {
            if (targetFolder.getName().equalsIgnoreCase(virtualFileOrFolder.getName())) {
                for (VirtualFile innerFileOrFolder : virtualFileOrFolder.getChildren()) {
                    copyFromWarToFolder(innerFileOrFolder, targetFolder);
                }
            } else {
                File innerTargetFolder = new File(targetFolder, virtualFileOrFolder.getName());
                innerTargetFolder.mkdir();
                for (VirtualFile innerFileOrFolder : virtualFileOrFolder.getChildren()) {
                    copyFromWarToFolder(innerFileOrFolder, innerTargetFolder);
                }
            }
        } else {
            File targetFile = new File(targetFolder, virtualFileOrFolder.getName());
            if (!targetFile.exists() || targetFile.length() != virtualFileOrFolder.getSize()) {
                FileUtils.copyURLToFile(virtualFileOrFolder.asFileURL(), targetFile);
            }
        }
    }
445113
public static boolean copyFile(String srcFile, String destFile) {
		boolean flag = false;
		FileInputStream fin = null;
		FileOutputStream fout = null;
		FileChannel fcin = null;
		FileChannel fcout = null;
		try {
			// 获取源文件和目标文件的输入输出流
			fin = new FileInputStream(srcFile);
			fout = new FileOutputStream(destFile);
			// 获取输入输出通道
			fcin = fin.getChannel();
			fcout = fout.getChannel();
			// 创建缓冲区
			ByteBuffer buffer = ByteBuffer.allocate(1024);
			while (true) {
				// clear方法重设缓冲区，使它可以接受读入的数据
				buffer.clear();
				// 从输入通道中将数据读到缓冲区
				int r = fcin.read(buffer);
				// read方法返回读取的字节数，可能为零，如果该通道已到达流的末尾，则返回-1
				if (r == -1) {
					flag = true;
					break;
				}
				// flip方法让缓冲区可以将新读入的数据写入另一个通道
				buffer.flip();
				// 从输出通道中将数据写入缓冲区
				fcout.write(buffer);
			}
			fout.flush();
		} catch (IOException e) {
			LogUtil.writeErrorLog("CopyFile fail", e);
		} finally {
			try {
				if (null != fin)
					fin.close();
				if (null != fout)
					fout.close();
				if (null != fcin)
					fcin.close();
				if (null != fcout)
					fcout.close();
			} catch (IOException ex) {
				LogUtil.writeErrorLog("Releases any system resources fail", ex);
			}
		}
		return flag;
	}
438111
public static void copyFile(File sourceFile, File destinationFile) throws FileNotFoundException, IOException {
		Streams.copyStream(new FileInputStream(sourceFile), new FileOutputStream(destinationFile), true);
	}