summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandy.jury2011-01-13 12:19:07 (EST)
committerRyan D. Brooks2011-01-13 12:19:07 (EST)
commit71e4ac4a261852aa75cb1f3b34698aaaacde87ce (patch)
tree3251a609faa7147d8ce30a41019759e5f8b3d87d
parentf2bc9bc2127ea34d634f1b7a2892285edf966111 (diff)
downloadorg.eclipse.osee-71e4ac4a261852aa75cb1f3b34698aaaacde87ce.zip
org.eclipse.osee-71e4ac4a261852aa75cb1f3b34698aaaacde87ce.tar.gz
org.eclipse.osee-71e4ac4a261852aa75cb1f3b34698aaaacde87ce.tar.bz2
bug: Make csv reader more robust
Previously, the csv reader would only read the last line if there was a new line after it. Now, change made so it will read last line whether there is a trailing new line or not.
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/CsvReader.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/CsvReader.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/CsvReader.java
index ab1caab..c8dd047 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/CsvReader.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/CsvReader.java
@@ -31,7 +31,7 @@ public class CsvReader {
/**
* @param file a comma separate value file
* @param totalNumFields the largest number of fields on any row (whether they are used or not)
- * @param enabled whether to enable or disable all the feilds initially
+ * @param enabled whether to enable or disable all the fields initially
*/
public CsvReader(File file, int totalNumFields, boolean enabled) throws IOException {
this(new BufferedReader(new FileReader(file)), totalNumFields, enabled);
@@ -112,6 +112,7 @@ public class CsvReader {
String[] values = new String[fieldCount];
int fieldIndex = 0;
int valuesIndex = 0;
+ boolean hasValueBeenRead = false;
while (streamTokenizer.nextToken() != StreamTokenizer.TT_EOL) {
if (streamTokenizer.ttype == ',') {
if (fieldsUsed[fieldIndex]) {
@@ -121,9 +122,14 @@ public class CsvReader {
} else if (streamTokenizer.ttype == StreamTokenizer.TT_WORD || streamTokenizer.ttype == '\"') {
if (fieldsUsed[fieldIndex]) {
values[valuesIndex] = streamTokenizer.sval;
+ hasValueBeenRead = true;
}
} else if (streamTokenizer.ttype == StreamTokenizer.TT_EOF) {
- return null;
+ if (hasValueBeenRead) {
+ return values;
+ } else {
+ return null;
+ }
} else {
throw new IllegalArgumentException("The token type was: " + streamTokenizer.ttype);
}