public class TXTReader extends Object
TXTReader reader = new TXTReader();
String sourceFilePath = "C:/Users/celli/Documents/my_doc.txt";
Set<String> lines = new HashSet<String>();
try {
lines = reader.parseTxt(sourceFilePath);
System.out.println("Found "+lines.size()+" lines");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
Constructor and Description |
---|
TXTReader() |
Modifier and Type | Method and Description |
---|---|
String |
getNextLine(Scanner scanner)
Get next line from a Scanner of a txt file
|
Map<String,List<String>> |
parseEqualCommaListValueTxt(String filepath)
Parse a text file of lines having a pattern key=value1,value2,value3,...
|
Map<String,List<String>> |
parseEqualMultipleKeysTxt(String filepath)
Parse a text file of lines having a pattern key=value.
|
Map<String,String> |
parseEqualTxt(String filepath)
Parse a text file of lines having a pattern key=value.
|
Map<String,String> |
parseTabPipeTxt(String filepath)
Parse a text file of lines having a pattern KEY\t|\tVALUE.
|
Set<String> |
parseTxt(String filepath)
Parse a text file of lines.
|
Map<String,String> |
reverseParseEqualTxt(String filepath)
Parse a text file of lines having a pattern key=value.
|
public Set<String> parseTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionpublic Map<String,String> parseTabPipeTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionpublic Map<String,String> parseEqualTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionpublic Map<String,List<String>> parseEqualCommaListValueTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionpublic Map<String,List<String>> parseEqualMultipleKeysTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionpublic Map<String,String> reverseParseEqualTxt(String filepath) throws FileNotFoundException
filepath
- the physical path of the fileFileNotFoundException
- FileNotFoundExceptionCopyright © 2016. All rights reserved.