Package org.jmxtrans.agent.util.io
Class IoUtils
java.lang.Object
org.jmxtrans.agent.util.io.IoUtils
public class IoUtils extends Object
- Author:
- Cyrille Le Clerc
-
Field Summary
-
Method Summary
Modifier and Type Method Description static voidappendToFile(File source, File destination, long maxFileSize, int maxBackupIndex, boolean prependNewLine)static voidcloseQuietly(Closeable closeable)static voidcloseQuietly(InputStream inputStream)Needed for old JVMs whereInputStreamdoes not implementCloseable.static voidcloseQuietly(Writer writer)static voidcloseQuietly(URLConnection cnn)static voidcopy(InputStream in, OutputStream out)static DocumentgetFileAsDocument(Resource resource)static longgetFileLastModificationDate(String filePath)static booleanisFileUrl(URL url)static voidreplaceFile(File source, File destination)static voidrollFiles(File destination, int maxBackupIndex)static booleanvalidateDestinationFile(File source, File destination, long maxFileSize, int maxBackupIndex)
-
Field Details
-
logger
-
-
Method Details
-
getFileLastModificationDate
public static long getFileLastModificationDate(@Nullable 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 Document getFileAsDocument(@Nonnull Resource resource) throws IoRuntimeException- Throws:
IoRuntimeException
-
isFileUrl
-
closeQuietly
-
closeQuietly
-
closeQuietly
-
closeQuietly
Needed for old JVMs whereInputStreamdoes not implementCloseable. -
replaceFile
- Throws:
IOException
-
appendToFile
public static void appendToFile(File source, File destination, long maxFileSize, int maxBackupIndex, boolean prependNewLine) throws IOException- Throws:
IOException
-
validateDestinationFile
public static boolean validateDestinationFile(File source, File destination, long maxFileSize, int maxBackupIndex) throws IOException- Throws:
IOException
-
rollFiles
- Throws:
IOException
-
copy
- Throws:
IOException
-