diff --git a/dbf-reader/src/main/java/org/jamel/dbf/DbfReader.java b/dbf-reader/src/main/java/org/jamel/dbf/DbfReader.java
index 468eb79..3511c6e 100644
--- a/dbf-reader/src/main/java/org/jamel/dbf/DbfReader.java
+++ b/dbf-reader/src/main/java/org/jamel/dbf/DbfReader.java
@@ -83,8 +83,37 @@ public void seekToRecord(int n) {
}
/**
- * Reads and returns the next row in the Dbf stream
+ * for custom user, only when you understand the file content
+ * @param length
+ */
+ public void skipBytes(int length) {
+ try {
+ dataInput.skipBytes(length);
+ } catch (IOException e) {
+ throw new DbfException("Cannot skip " + length + " bytes", e);
+ }
+ }
+
+ /**
*
+ * for custom user, only when you understand the file content
+ * @param length
+ * @return
+ */
+ public byte[] readBytes(int length) {
+ byte[] bytes = new byte[length];
+ try {
+ dataInput.readFully(bytes);
+ return bytes;
+ } catch (IOException e) {
+ throw new DbfException("Cannot read " + length + " bytes", e);
+ }
+ }
+
+ /**
+ * Reads and returns the next row in the Dbf stream
+ * a deleted row start with "*"
+ * a normal row start with " "
* @return The next row as an Object array.
*/
public Object[] nextRecord() {
@@ -111,6 +140,31 @@ public Object[] nextRecord() {
}
}
+ /**
+ * Reads and returns the next row in the Dbf stream
+ * a deleted row start with "*"
+ * a normal row start with " "
+ * so we just ignore the first byte
+ * @return The next row as an Object array.
+ */
+ public Object[] nextRecordIgnoreDelete() {
+ try {
+ int nextByte = dataInput.readByte();
+ if (nextByte == DATA_ENDED) {
+ return null;
+ }
+ Object recordObjects[] = new Object[header.getFieldsCount()];
+ for (int i = 0; i < header.getFieldsCount(); i++) {
+ recordObjects[i] = readFieldValue(header.getField(i));
+ }
+ return recordObjects;
+ } catch (EOFException e) {
+ return null; // we currently end reading file
+ } catch (IOException e) {
+ throw new DbfException("Cannot read next record form Dbf file", e);
+ }
+ }
+
private Object readFieldValue(DbfField field) throws IOException {
byte buf[] = new byte[field.getFieldLength()];
dataInput.readFully(buf);
@@ -154,7 +208,7 @@ protected Boolean readLogicalValue(DbfField field, byte[] buf) throws IOExceptio
protected Number readNumericValue(DbfField field, byte[] buf) throws IOException {
try {
byte[] numericBuf = DbfUtils.trimLeftSpaces(buf);
- boolean processable = numericBuf.length > 0 && !DbfUtils.contains(numericBuf, (byte) '?');
+ boolean processable = numericBuf.length > 0 && !DbfUtils.contains(numericBuf, (byte) '?') && !DbfUtils.contains(numericBuf, (byte) '-');
return processable ? Double.valueOf(new String(numericBuf)) : null;
} catch (NumberFormatException e) {
throw new DbfException("Failed to parse Number from " + field.getName(), e);