|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.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.
public static String getBinaryResult(String pathToBinary, String cmdLineOpts)
pathToBinary
- Full path to the binary to be run, including its name.cmdLineOpts
- Command line options to be passed to the binary.
public static void writeString(String s, File f)
s
- String to be written.f
- File to be written to.public static void appendString(String s, File f)
s
- String to be appended.f
- File to be written to.public static void readerToBuilder(Reader r, StringBuilder sb) throws InterruptedException, IOException
Reader
and writes its content to the specified
StringBuilder
.
r
- Reader to read from.sb
- String buffer to write to.
InterruptedException
- If the thread is interrupted.
IOException
- If there is a problem with reading.public static String loadTemplate(String resource) throws IOException, InterruptedException
resource
- Path to the Java resource.
InterruptedException
- If the thread is interrupted.
IOException
- If there is a problem with reading.
|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |