Commit 136ec28d authored by Christian Wulf's avatar Christian Wulf

closes 302

parent 7aacfa52
......@@ -63,15 +63,17 @@ public final class File2TextLinesFilter extends AbstractConsumerStage<File> {
@Override
protected void execute(final File textFile) {
int lineNumber = 1;
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(textFile), this.charset));
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.length() != 0) {
outputPort.send(new TextLineContainer(textFile, line));
String textLine;
while ((textLine = reader.readLine()) != null) {
textLine = textLine.trim();
if (textLine.length() != 0) {
outputPort.send(new TextLineContainer(textFile, textLine, lineNumber));
} // else: ignore empty line
lineNumber++;
}
} catch (final FileNotFoundException e) {
this.logger.error("", e);
......
......@@ -24,10 +24,12 @@ public class TextLineContainer {
private final File textFile;
private final String textLine;
private final int lineNumber;
public TextLineContainer(final File textFile, final String textLine) {
public TextLineContainer(final File textFile, final String textLine, final int lineNumber) {
this.textFile = textFile;
this.textLine = textLine;
this.lineNumber = lineNumber;
}
public File getTextFile() {
......@@ -37,4 +39,9 @@ public class TextLineContainer {
public String getTextLine() {
return this.textLine;
}
@Override
public String toString() {
return "Line " + lineNumber + ": " + textLine;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment