|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jezhumble.javasysmon.FileUtils
public class FileUtils
Convenience methods for interacting with the filesystem.
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
java.lang.String[] |
pidsFromProcFilesystem()
If you're using an operating system that supports the proc filesystem, this returns a list of all processes by reading the directories under /proc |
java.lang.String |
runRegexOnFile(java.util.regex.Pattern pattern,
java.lang.String filename)
Runs a regular expression on a file, and returns the first match. |
java.lang.String |
slurp(java.lang.String fileName)
Given a filename, reads the entire file into a string. |
java.lang.String |
slurpFromInputStream(java.io.InputStream stream)
Given an InputStream, reads the entire file into a string. |
byte[] |
slurpToByteArray(java.lang.String fileName)
Given a filename, reads the entire file into a byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public java.lang.String[] pidsFromProcFilesystem()
public java.lang.String slurp(java.lang.String fileName) throws java.io.IOException
fileName
- The path of the filename to read. Should be absolute.
java.io.IOException
- If there's an IO exception while trying to read the filepublic byte[] slurpToByteArray(java.lang.String fileName) throws java.io.IOException
fileName
- The path of the filename to read. Should be absolute.
java.io.IOException
- If there's an IO exception while trying to read the filepublic java.lang.String slurpFromInputStream(java.io.InputStream stream) throws java.io.IOException
stream
- The InputStream representing the file to read
java.io.IOException
- If there's an IO exception while trying to read the input streampublic java.lang.String runRegexOnFile(java.util.regex.Pattern pattern, java.lang.String filename)
pattern
- The regular expression to use.filename
- The path of the filename to match against. Should be absolute.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |