|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.mff.ksi.jinfer.base.utils.FileUtils
public final class FileUtils
Utilities for file handling.
Field Summary | |
---|---|
static String |
JINFER_DIR
|
Method Summary | |
---|---|
static void |
appendString(String s,
File f)
Appends the specified string to the specified file. |
static String |
getBinaryResult(String pathToBinary,
String cmdLineOpts)
Returns the first line of the stdout of the specified program run. |
static String |
getExtension(String fileName)
Returns the extension of the provided file. |
static boolean |
isBinaryValid(String pathToBinary,
String cmdLineOpts,
String expectedFirstLine,
boolean isEmptyValid)
Checks whether the provided path is a path to a valid executable binary that can be run and produces expected result. |
static String |
loadTemplate(String resource)
Loads the specified resource file and returns it as String. |
static void |
readerToBuilder(Reader r,
StringBuilder sb)
Reads the specified Reader and writes its content to the specified
StringBuilder . |
static void |
writeString(String s,
File f)
Writes the specified string to the specified file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String JINFER_DIR
Method Detail |
---|
public static String getExtension(String fileName)
public static boolean isBinaryValid(String pathToBinary, String cmdLineOpts, String expectedFirstLine, boolean isEmptyValid)
pathToBinary
- Full path to the binary to be checked, including its
name.cmdLineOpts
- Options to be passed to the binary (such as -v
).expectedFirstLine
- Expected beginning of the first line this binary
should produce. This is checked for stdout as well as
stderr
, it is enough to find it in one of these places.
isEmptyValid
- Whether to accept an empty path to binary as valid.
Returns:
True
if the specified path is either empty and that
is OK, or if the path points to an executable file that, after being
executed with provided options, produces the expected output.
False otherwise.
getBinaryResult
public static String getBinaryResult(String pathToBinary,
String cmdLineOpts)
- Returns the first line of the stdout of the specified program run.
- Parameters:
pathToBinary
- Full path to the binary to be run, including its name.cmdLineOpts
- Command line options to be passed to the binary.
- Returns:
- First line of the standard output of this program.
writeString
public static void writeString(String s,
File f)
- Writes the specified string to the specified file. It tries to create all
the necessary folders on the way to the file.
- Parameters:
s
- String to be written.f
- File to be written to.
appendString
public static void appendString(String s,
File f)
- Appends the specified string to the specified file. It tries to create all
the necessary folders on the way to the file.
- Parameters:
s
- String to be appended.f
- File to be written to.
readerToBuilder
public static void readerToBuilder(Reader r,
StringBuilder sb)
throws InterruptedException,
IOException
- Reads the specified
Reader
and writes its content to the specified
StringBuilder
.
- Parameters:
r
- Reader to read from.sb
- String buffer to write to.
- Throws:
InterruptedException
- If the thread is interrupted.
IOException
- If there is a problem with reading.
loadTemplate
public static String loadTemplate(String resource)
throws IOException,
InterruptedException
- Loads the specified resource file and returns it as String.
- Parameters:
resource
- Path to the Java resource.
- Returns:
- String content of the resource file.
- Throws:
InterruptedException
- If the thread is interrupted.
IOException
- If there is a problem with reading.
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
jInfer
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Generated on Fri Dec 9 00:01:25 CET 2011