public class FileUtils
extends java.lang.Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
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.
|
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 readjava.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.Copyright © 2009 ThoughtWorks. All Rights Reserved.