Skip to content

Commit

Permalink
Simplify example program in README.md
Browse files Browse the repository at this point in the history
Remove unnecessary try-catch block, use relative path to real cars.dbf file.
  • Loading branch information
simoc committed Mar 23, 2016
1 parent 4989140 commit 157b237
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,28 @@ import java.io.File;
import java.util.Iterator;
import java.util.List;

public class DansDemo
public class DansDbfDemo
{
public static void main(String []args)
public static void main(String []args) throws Exception
{
try
File dbfFile = new File("src/test/resources/dbase3plus/cars/cars.dbf");
Table table = new Table(dbfFile);
table.open(IfNonExistent.ERROR);
List<Field> fields = table.getFields();
Iterator<Record> it = table.recordIterator();
while (it.hasNext())
{
Table table = new Table(new File("/tmp", "cars.dbf"));
table.open(IfNonExistent.ERROR);
List<Field> fields = table.getFields();
Iterator<Record> it = table.recordIterator();
while (it.hasNext())
Record record = it.next();
for (Field field: fields)
{
Record record = it.next();
for (Field field: fields)
{
System.out.print(field.getName());
System.out.print(": ");
System.out.print(field.getType());
System.out.print(": ");
System.out.println(record.getTypedValue(field.getName()));
}
System.out.print(field.getName());
System.out.print(": ");
System.out.print(field.getType());
System.out.print(": ");
System.out.println(record.getTypedValue(field.getName()));
}
table.close();
}
catch (Exception e)
{
e.printStackTrace();
}
table.close();
}
}
```
Expand Down

0 comments on commit 157b237

Please sign in to comment.