Class FileUtil

java.lang.Object
net.sourceforge.jbizmo.commons.file.FileUtil

public class FileUtil extends Object

Utility class for file operations

Copyright 2010 (C) by Martin Ganserer

Version:
1.0.0
Author:
Martin Ganserer
  • Method Details

    • copyFile

      public static void copyFile(File sourceFile, File targetFile) throws IOException
      Copy a file and replace the target file if it already exists
      Parameters:
      sourceFile -
      targetFile -
      Throws:
      IOException - if the copy operation has failed
    • getUniqueFileName

      public static String getUniqueFileName(String groupName)
      Get a unique file name to the save file to a central repository
      Parameters:
      groupName - a token in order to distinguish between files that belong to different domain objects
      Returns:
      the generated file name
    • getBytesFromFile

      public static byte[] getBytesFromFile(File file) throws IOException
      Get the contents of the file as a byte array
      Parameters:
      file - the file this method should read data from
      Returns:
      a byte array with the content of the file
      Throws:
      IOException - if the content could not be read
    • convertToByteArray

      public static Byte[] convertToByteArray(byte[] array)
      Convert a byte[] into a Byte[]
      Parameters:
      array -
      Returns:
      the converted array
    • convertToByteArray

      public static byte[] convertToByteArray(Byte[] array)
      Convert a given Byte[] into a byte[]
      Parameters:
      array -
      Returns:
      the converted array