randoop.util
Class Files

Object
  extended by Files

public final class Files
extends Object


Method Summary
Modifier and Type Method and Description
static String addProjectPath(String string)
           
static void cat(String filename)
          Prints out the contents of the give file to stdout.
static int countLines(String filename)
          Returns the number of lines in the given file.
static boolean deleteFile(String path)
           
static boolean deleteRecursive(File dir)
           
static List<String> findFilesInDir(File dir, String startsWith, String endsWith)
           
static String getFileContents(File file)
          Reads the whole file.
static String getFileContents(String path)
          Reads the whole file.
static LineNumberReader getFileReader(File fileName)
           
static LineNumberReader getFileReader(String fileName)
           
static Long readLongFromFile(File file)
          Reads a single long from the file.
static List<String> readWhole(BufferedReader reader)
          Reads the whole file.
static List<String> readWhole(File file)
          Reads the whole file.
static List<String> readWhole(InputStream is)
          Reads the whole file.
static List<String> readWhole(String fileName)
          Reads the whole file.
static void writeToFile(List<String> lines, String fileName)
           
static void writeToFile(String s, File file)
           
static void writeToFile(String s, File file, Boolean append)
           
static void writeToFile(String s, String fileName)
           
static void writeToFile(String s, String fileName, Boolean append)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deleteRecursive

public static boolean deleteRecursive(File dir)

findFilesInDir

public static List<String> findFilesInDir(File dir,
                                          String startsWith,
                                          String endsWith)

writeToFile

public static void writeToFile(String s,
                               File file)
                        throws IOException
Throws:
IOException

writeToFile

public static void writeToFile(String s,
                               String fileName)
                        throws IOException
Throws:
IOException

writeToFile

public static void writeToFile(String s,
                               File file,
                               Boolean append)
                        throws IOException
Throws:
IOException

writeToFile

public static void writeToFile(String s,
                               String fileName,
                               Boolean append)
                        throws IOException
Throws:
IOException

writeToFile

public static void writeToFile(List<String> lines,
                               String fileName)
                        throws IOException
Throws:
IOException

readWhole

public static List<String> readWhole(BufferedReader reader)
                              throws IOException
Reads the whole file. Does not close the reader. Returns the list of lines.

Throws:
IOException

readWhole

public static List<String> readWhole(String fileName)
                              throws IOException
Reads the whole file. Returns the list of lines.

Throws:
IOException

readWhole

public static List<String> readWhole(File file)
                              throws IOException
Reads the whole file. Returns the list of lines.

Throws:
IOException

readWhole

public static List<String> readWhole(InputStream is)
                              throws IOException
Reads the whole file. Returns the list of lines. Does not close the stream.

Throws:
IOException

getFileContents

public static String getFileContents(File file)
                              throws IOException
Reads the whole file. Returns one big String.

Throws:
IOException

getFileContents

public static String getFileContents(String path)
                              throws IOException
Reads the whole file. Returns one big String.

Throws:
IOException

getFileReader

public static LineNumberReader getFileReader(String fileName)

getFileReader

public static LineNumberReader getFileReader(File fileName)

addProjectPath

public static String addProjectPath(String string)

deleteFile

public static boolean deleteFile(String path)

readLongFromFile

public static Long readLongFromFile(File file)
Reads a single long from the file. Returns null if the file does not exist.

Throws:
IllegalStateException - is the file contains not just 1 line or if the file contains something.

cat

public static void cat(String filename)
Prints out the contents of the give file to stdout.


countLines

public static int countLines(String filename)
Returns the number of lines in the given file.