Creates a buffered image containing the diff of both files.

@param firstFile
@param secondFile
@return
@throws IOException
420390
public BufferedImage createDiffImage(BufferedImage firstImage,
			BufferedImage secondImage) throws IOException {
		BufferedImage diffImage = new BufferedImage(firstImage.getWidth(),
				firstImage.getHeight(), IMAGE_TYPE);

		for (int x = 0; x < firstImage.getWidth() && x < secondImage.getWidth(); x++) {
			for (int y = 0; y < firstImage.getHeight()
					&& y < secondImage.getHeight(); y++) {
				int pixelA = firstImage.getRGB(x, y);
				int pixelB = secondImage.getRGB(x, y);
				int diffRGB = Math.abs(pixelA - pixelB);
				diffImage.setRGB(x, y, diffRGB);
			}
		}
		return diffImage;
	}
121407
public BufferedImage createImage(File file) throws IOException {
		resetAvailabilityFlags();
		this.data = PELoader.loadPE(file);
		image = new BufferedImage(fileWidth, height, IMAGE_TYPE);

		drawSections();

		Overlay overlay = new Overlay(data);
		if (overlay.exists()) {
			long overlayOffset = overlay.getOffset();
			drawPixels(colorMap.get(OVERLAY), overlayOffset,
					withMinLength(overlay.getSize()));
			overlayAvailable = true;
		}

		drawPEHeaders();
		drawSpecials();
		drawResourceTypes();
		assert image != null;
		assert image.getWidth() == fileWidth;
		assert image.getHeight() == height;
		return image;
	}
1268876
private void createDirAndFile(Path path) throws IOException {
			// create dir and file first if dir/file not exist
			File file = new File(path.toAbsolutePath().toString());
			File dir = file.getParentFile();
			if (dir != null && !dir.exists()) {
				dir.mkdirs();
			}
			if (!file.exists()) {
				file.createNewFile();
			}
	}
463220
public Diff compare(File f1, File f2) throws Exception {
		return this.compare(getCtType(f1), getCtType(f2));
	}
342594
public static void copy(File sourceFile, File targetFile) throws IOException {
	FileInputStream in = new FileInputStream(sourceFile);
	try {
	    FileOutputStream out = new FileOutputStream(targetFile);
	    try {
		copy(in, out);
	    } finally {
		out.close();
	    }
	} finally {
	    in.close();
	}
    }
76454
public static void copy(InputStream is, File file) throws IOException {

		Asserts.notNullParameter("is", is);
		Asserts.notNullParameter("file", file);
		
		FileOutputStream os = null;
		os = new FileOutputStream(file);
		copy(is, os);
	}
434910
public static boolean createNewFile(File targetFile) {
        if (targetFile.exists()) delFileOrFolder(targetFile);
        try {
            return targetFile.createNewFile();
        } catch (IOException e) {
            return false;
        }
    }
697306
public boolean createNewFile(Path f) throws IOException {
    if (exists(f)) {
      return false;
    } else {
      create(f, false, getDefaultBufferSize()).close();
      return true;
    }
  }
439097
public static void mergeTiff(List<IIOImage> imageList, File outputTiff) throws IOException {
        mergeTiff(imageList, outputTiff, null);
    }
1105722
public static File copyIntoTempFile(String fileName, InputStream inputStream)
      throws IOException {
    BufferedInputStream bufferedStream = inputStream instanceof BufferedInputStream ? (BufferedInputStream) inputStream
        : new BufferedInputStream(inputStream);
    File destFile = null;
    try {
      destFile = File.createTempFile(fileName, null);
      destFile.deleteOnExit();

      FileOutputStream fileOutputStream = new FileOutputStream(destFile);
      BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
      try {
        byte[] buffer = new byte[8192];
        int length;
        while ((length = bufferedStream.read(buffer)) > 0) {
          bufferedOutputStream.write(buffer, 0, length);
        }
      } finally {
        bufferedOutputStream.close();
        fileOutputStream.close();
      }
    } finally {
      bufferedStream.close();
      inputStream.close();
    }
    return destFile;
  }
18603
protected void copyFile(File src, File dest, Replacement replaceFn) throws IOException {
        boolean isSource = isSourceFile(src);
        copyFile(src, dest, replaceFn, isSource);
    }
358078
public static void writeFile(VirtualFile virtualFile, byte[] bytes) throws IOException {
        final File file = virtualFile.getPhysicalFile();
        file.getParentFile().mkdirs();
        final FileOutputStream fos = new FileOutputStream(file);
        try {
            fos.write(bytes);
            fos.close();
        } finally {
            safeClose(fos);
        }
    }
687918
public static void mergeTiff(BufferedImage[] inputImages, File outputTiff) throws IOException {
        mergeTiff(inputImages, outputTiff, null);
    }
54667
public static boolean isFileEqual(File oldFile, File newFile) {

        try {

            return contentEquals(oldFile, newFile);

        } catch (IOException e) {

            logger.warn(e.toString());
            return false;
        }

    }
917073
private void mergeFiles(List<File> inputFiles, OutputStream outputStream)
      throws IOException {
    long startTime = System.nanoTime();

    //Merge files
    for (File f : inputFiles) {
      if (f.exists()) {
        FileInputStream fileInputStream = new FileInputStream(f);
        BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
        try {
          LOGGER.log(Level.INFO, "Merging {0} size={1}", new Object[]{f.getName(), f.length()});

          byte[] buffer = new byte[8192];
          int length;
          while ((length = bufferedInputStream.read(buffer)) > 0) {
            outputStream.write(buffer, 0, length);
          }
        } finally {
          bufferedInputStream.close();
          fileInputStream.close();
        }
      } else {
        LOGGER.log(Level.INFO, "Skip merging file {0} because it doesn't exist", f.getName());
      }
    }

    LOGGER.log(Level.INFO, "Time to merge {0} s", ((System.nanoTime() - startTime) / 1000000000.0));
  }
839368
public static ByteBuffer readFile(File inFile) throws IOException {
        ByteBuffer mBuf;
        try (FileInputStream fIn = new FileInputStream(inFile);
             FileChannel fChan = fIn.getChannel()) {
            long fSize = fChan.size();
            mBuf = ByteBuffer.allocate((int) fSize);
            fChan.read(mBuf);
            mBuf.rewind();
        }
        return mBuf;
    }
667949
public static IFileContentResultBean compareFileContentByBytes(final File sourceFile,
		final File fileToCompare)
	{
		final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile,
			fileToCompare);
		completeCompare(fileContentResultBean);
		final boolean simpleEquality = validateEquality(fileContentResultBean);
		boolean contentEquality = true;
		// Compare the content...
		if (simpleEquality)
		{
			try (InputStream sourceReader = StreamExtensions.getInputStream(sourceFile);
				InputStream compareReader = StreamExtensions.getInputStream(fileToCompare);)
			{

				final byte[] source = StreamExtensions.getByteArray(sourceReader);
				final byte[] compare = StreamExtensions.getByteArray(compareReader);

				for (int i = 0; 0 < source.length; i++)
				{
					if (source[i] != compare[i])
					{
						contentEquality = false;
						break;
					}
				}
			}
			catch (final FileNotFoundException e)
			{
				contentEquality = false;
			}
			catch (final IOException e)
			{
				contentEquality = false;
			}
		}
		fileContentResultBean.setContentEquality(contentEquality);
		return fileContentResultBean;
	}