public class FileUtils extends Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
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
|
String |
runRegexOnFile(Pattern pattern,
String filename)
Runs a regular expression on a file, and returns the first match.
|
String |
slurp(String fileName)
Given a filename, reads the entire file into a string.
|
String |
slurpFromInputStream(InputStream stream)
Given an InputStream, reads the entire file into a string.
|
byte[] |
slurpToByteArray(String fileName)
Given a filename, reads the entire file into a byte array.
|
public String[] pidsFromProcFilesystem()
public String slurp(String fileName) throws IOException
fileName
- The path of the filename to read. Should be absolute.IOException
- If there's an IO exception while trying to read the filepublic byte[] slurpToByteArray(String fileName) throws IOException
fileName
- The path of the filename to read. Should be absolute.IOException
- If there's an IO exception while trying to read the filepublic String slurpFromInputStream(InputStream stream) throws IOException
stream
- The InputStream representing the file to readIOException
- If there's an IO exception while trying to read the input streampublic String runRegexOnFile(Pattern pattern, 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.