You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2007/10/08 08:40:06 UTC

svn commit: r582723 - /ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java

Author: jleroux
Date: Sun Oct  7 23:40:05 2007
New Revision: 582723

URL: http://svn.apache.org/viewvc?rev=582723&view=rev
Log:
To allow to deal with problems in some DOS file, specifically file extracted from zip archives.

Modified:
    ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java

Modified: ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java?rev=582723&r1=582722&r2=582723&view=diff
==============================================================================
--- ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java (original)
+++ ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/RecordIterator.java Sun Oct  7 23:40:05 2007
@@ -47,6 +47,7 @@
     protected Record curRecord = null;
     protected String nextLine = null;
     protected Record nextRecord = null;
+    protected String eof = new String("\u001A"); // aka ASCII char 26, aka substitute, aka  0x1A, aka CTRL-Z, aka EOF DOS character. Added because problems in some DOS file, specifically file extracted from zip archives.
     
     public RecordIterator(URL fileUrl, ModelDataFile modelDataFile) throws DataFileException {
         this.modelDataFile = modelDataFile;
@@ -115,7 +116,7 @@
             }
         }
         
-        if (nextLine != null) {
+        if (nextLine != null && !(eof.equals(nextLine.substring(0,1)) && 1 == nextLine.length())) {
             nextLineNum++;
             ModelRecord modelRecord = findModelForLine(nextLine, nextLineNum, modelDataFile);
             if (isDelimited) {
@@ -135,7 +136,8 @@
     }
     
     public boolean hasNext() {
-        return nextLine != null;
+        return nextLine != null && !(eof.equals(nextLine.substring(0,1)) && 1 == nextLine.length());
+        
     }
     
     public Record next() throws DataFileException {