Changeset 175 for trunk/JavaHelperLib/src/de/ugoe/cs/util/FileTools.java
- Timestamp:
- 09/09/11 23:52:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaHelperLib/src/de/ugoe/cs/util/FileTools.java
r83 r175 6 6 import java.io.IOException; 7 7 8 /** 9 * <p> 10 * Helper class that provides methods that simplify working with files. 11 * </p> 12 * 13 * @author Steffen Herbold 14 * @version 1.0 15 */ 8 16 public class FileTools { 9 17 10 18 /** 11 19 * <p> 12 * Returns an array of the lines contained in a file. The line seperator is "\r\n". 20 * Returns an array of the lines contained in a file. The line separator is 21 * "\r\n". 13 22 * </p> 14 * @param filename name of the file 23 * 24 * @param filename 25 * name of the file 15 26 * @return string array, where each line contains a file 16 * @throws IOException see {@link FileReader#read(char[])}, {@link FileReader#close()} 17 * @throws FileNotFoundException see {@link FileReader#FileReader(File)} 27 * @throws IOException 28 * see {@link FileReader#read(char[])}, 29 * {@link FileReader#close()} 30 * @throws FileNotFoundException 31 * see {@link FileReader#FileReader(File)} 18 32 */ 19 public static String[] getLinesFromFile(String filename) throws IOException, FileNotFoundException { 33 public static String[] getLinesFromFile(String filename) 34 throws IOException, FileNotFoundException { 20 35 return getLinesFromFile(filename, true); 21 36 } 22 37 23 38 /** 24 39 * <p> 25 40 * Returns an array of the lines contained in a file. 26 41 * </p> 27 * @param filename name of the file 28 * @param carriageReturn if true, "\r\n", if false "\n" is used as line seperator 42 * 43 * @param filename 44 * name of the file 45 * @param carriageReturn 46 * if true, "\r\n", if false "\n" is used as line separator 29 47 * @return string array, where each line contains a file 30 * @throws IOException see {@link FileReader#read(char[])}, {@link FileReader#close()} 31 * @throws FileNotFoundException see {@link FileReader#FileReader(File)} 48 * @throws IOException 49 * see {@link FileReader#read(char[])}, 50 * {@link FileReader#close()} 51 * @throws FileNotFoundException 52 * see {@link FileReader#FileReader(File)} 32 53 */ 33 public static String[] getLinesFromFile(String filename, boolean carriageReturn) throws IOException, FileNotFoundException { 54 public static String[] getLinesFromFile(String filename, 55 boolean carriageReturn) throws IOException, FileNotFoundException { 34 56 File f = new File(filename); 35 57 FileReader reader = new FileReader(f); … … 38 60 reader.close(); 39 61 String splitString; 40 if ( carriageReturn) {62 if (carriageReturn) { 41 63 splitString = "\r\n"; 42 64 } else {
Note: See TracChangeset
for help on using the changeset viewer.