public class OsUtil
extends java.lang.Object
FileSystemUtil
Constructor and Description |
---|
OsUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(java.io.InputStream input)
Unconditionally close an
Reader . |
static boolean |
contentEquals(java.io.File file1,
java.io.File file2)
Compare the contents of two files to determine if they are equal or not.
|
static boolean |
contentEquals(java.io.InputStream input1,
java.io.InputStream input2)
Compare the contents of two Streams to determine if they are equal or
not.
|
static java.lang.String |
getProcessId(java.lang.String fallback)
return the processID (pid), or the fallback if the pid cannot be found.
|
public static java.lang.String getProcessId(java.lang.String fallback)
fallback
- the string (null is okay) to return when the pid cannot be found.public static void closeQuietly(java.io.InputStream input)
Reader
.
Equivalent to Reader.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
From apache commons. http://grepcode.com/file_/repo1.maven.org/maven2/commons-io/commons-io/1.2/org/apache/commons/io/IOUtils.java/?v=source
input
- the Reader to close, may be null or already closedpublic static boolean contentEquals(java.io.InputStream input1, java.io.InputStream input2) throws java.io.IOException
This method buffers the input internally using
BufferedInputStream
if they are not already buffered.
input1
- the first streaminput2
- the second streamjava.lang.NullPointerException
- if either input is nulljava.io.IOException
- if an I/O error occurs
From Apache Commons http://grepcode.com/file_/repo1.maven.org/maven2/commons-io/commons-io/1.2/org/apache/commons/io/IOUtils.java/?v=sourcepublic static boolean contentEquals(java.io.File file1, java.io.File file2) throws java.io.IOException
This method checks to see if the two files are different lengths or if they point to the same file, before resorting to byte-by-byte comparison of the contents.
Code origin: Avalon
file1
- the first filefile2
- the second filejava.io.IOException
- in case of an I/O error
From Apache Commons http://grepcode.com/file/repo1.maven.org/maven2/commons-io/commons-io/1.2/org/apache/commons/io/FileUtils.java