Class IoUtils

java.lang.Object
org.jmxtrans.agent.util.io.IoUtils

public class IoUtils
extends java.lang.Object
Author:
Cyrille Le Clerc
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected static Logger logger  
  • Method Summary

    Modifier and Type Method Description
    static void appendToFile​(java.io.File source, java.io.File destination, long maxFileSize, int maxBackupIndex, boolean prependNewLine)  
    static void closeQuietly​(java.io.Closeable closeable)  
    static void closeQuietly​(java.io.InputStream inputStream)
    Needed for old JVMs where InputStream does not implement Closeable.
    static void closeQuietly​(java.io.Writer writer)  
    static void closeQuietly​(java.net.URLConnection cnn)  
    static void copy​(java.io.InputStream in, java.io.OutputStream out)  
    static org.w3c.dom.Document getFileAsDocument​(Resource resource)  
    static long getFileLastModificationDate​(java.lang.String filePath)  
    static boolean isFileUrl​(java.net.URL url)  
    static void replaceFile​(java.io.File source, java.io.File destination)  
    static void rollFiles​(java.io.File destination, int maxBackupIndex)  
    static boolean validateDestinationFile​(java.io.File source, java.io.File destination, long maxFileSize, int maxBackupIndex)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected static final Logger logger
  • Method Details

    • getFileLastModificationDate

      public static long getFileLastModificationDate​(@Nullable java.lang.String filePath) throws IoRuntimeException
      Parameters:
      filePath - can be prefixed by "http://", "https://", "file://". If given value is not prefixed, "file://" is assumed.
      Returns:
      Throws:
      IoRuntimeException
    • getFileAsDocument

      @Nonnull public static org.w3c.dom.Document getFileAsDocument​(@Nonnull Resource resource) throws IoRuntimeException
      Throws:
      IoRuntimeException
    • isFileUrl

      public static boolean isFileUrl​(java.net.URL url)
    • closeQuietly

      public static void closeQuietly​(java.net.URLConnection cnn)
    • closeQuietly

      public static void closeQuietly​(java.io.Closeable closeable)
    • closeQuietly

      public static void closeQuietly​(java.io.Writer writer)
    • closeQuietly

      public static void closeQuietly​(java.io.InputStream inputStream)
      Needed for old JVMs where InputStream does not implement Closeable.
    • replaceFile

      public static void replaceFile​(java.io.File source, java.io.File destination) throws java.io.IOException
      Throws:
      java.io.IOException
    • appendToFile

      public static void appendToFile​(java.io.File source, java.io.File destination, long maxFileSize, int maxBackupIndex, boolean prependNewLine) throws java.io.IOException
      Throws:
      java.io.IOException
    • validateDestinationFile

      public static boolean validateDestinationFile​(java.io.File source, java.io.File destination, long maxFileSize, int maxBackupIndex) throws java.io.IOException
      Throws:
      java.io.IOException
    • rollFiles

      public static void rollFiles​(java.io.File destination, int maxBackupIndex) throws java.io.IOException
      Throws:
      java.io.IOException
    • copy

      public static void copy​(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
      Throws:
      java.io.IOException