Package org.jmxtrans.agent.util.io
Class IoUtils
java.lang.Object
org.jmxtrans.agent.util.io.IoUtils
public class IoUtils
extends java.lang.Object
- Author:
- Cyrille Le Clerc
-
Field Summary
-
Method Summary
Modifier and Type Method Description static voidappendToFile(java.io.File source, java.io.File destination, long maxFileSize, int maxBackupIndex, boolean prependNewLine)static voidcloseQuietly(java.io.Closeable closeable)static voidcloseQuietly(java.io.InputStream inputStream)Needed for old JVMs whereInputStreamdoes not implementCloseable.static voidcloseQuietly(java.io.Writer writer)static voidcloseQuietly(java.net.URLConnection cnn)static voidcopy(java.io.InputStream in, java.io.OutputStream out)static org.w3c.dom.DocumentgetFileAsDocument(Resource resource)static longgetFileLastModificationDate(java.lang.String filePath)static booleanisFileUrl(java.net.URL url)static voidreplaceFile(java.io.File source, java.io.File destination)static voidrollFiles(java.io.File destination, int maxBackupIndex)static booleanvalidateDestinationFile(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
-
-
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 whereInputStreamdoes not implementCloseable. -
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
-