Class FileUtils

java.lang.Object
at.gv.egovernment.moaspss.util.FileUtils

public class FileUtils extends Object
Utility for accessing files on the file system, and for reading from input streams.
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • readURL

      public static byte[] readURL(String urlString) throws IOException
      Reads a file, given by URL, into a byte array.
      Parameters:
      urlString - file URL
      Returns:
      file content
      Throws:
      IOException - on any exception thrown
    • readURL

      public static String readURL(String urlString, String encoding) throws IOException
      Reads a file, given by URL, into a String.
      Parameters:
      urlString - file URL
      encoding - character encoding
      Returns:
      file content
      Throws:
      IOException - on any exception thrown
    • readFile

      public static byte[] readFile(String filename) throws IOException
      Reads a file, given by filename, into a byte array.
      Parameters:
      filename - filename
      Returns:
      file content
      Throws:
      IOException - on any exception thrown
    • readFile

      public static String readFile(String filename, String encoding) throws IOException
      Reads a file, given by filename, into a String.
      Parameters:
      filename - filename
      encoding - character encoding
      Returns:
      file content
      Throws:
      IOException - on any exception thrown
    • readResource

      public static byte[] readResource(String name) throws IOException
      Reads a file from a resource.
      Parameters:
      name - resource name
      Returns:
      file content as a byte array
      Throws:
      IOException - on any exception thrown
    • readResource

      public static String readResource(String name, String encoding) throws IOException
      Reads a file from a resource.
      Parameters:
      name - filename
      encoding - character encoding
      Returns:
      file content
      Throws:
      IOException - on any exception thrown
    • makeAbsoluteURL

      public static String makeAbsoluteURL(String url, String root)
      Returns the absolute URL of a given url which is relative to the parameter root
      Parameters:
      url -
      root -
      Returns:
      String
    • copyFile

      public static void copyFile(File src, File dest)