STEP 1: Download jar file & add in ur project
DOwnload link :http://www.java2s.com/Code/Jar/c/Downloadcomlinuxense10jar.htm
Step 2:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package jdbf;
/**
*
* @author saurabh-it
*/
import java.io.*;
import com.linuxense.javadbf.*;
public class JavaDBFReaderTest {
public static void main( String args[]) {
try {
// create a DBFReader object
//
InputStream inputStream = new FileInputStream("PATH_OF _UR_.DBF_FILE"); // take dbf file as program argument
DBFReader reader = new DBFReader( inputStream);
// get the field count if you want for some reasons like the following
//
int numberOfFields = reader.getFieldCount();
// use this count to fetch all field information
// if required
//
for( int i=0; i<numberOfFields; i++) {
DBFField field = reader.getField( i);
// do something with it if you want
// refer the JavaDoc API reference for more details
//
System.out.println( field.getName());
}
// Now, lets us start reading the rows
//
Object []rowObjects;
while( (rowObjects = reader.nextRecord()) != null) {
for( int i=0; i<rowObjects.length; i++) {
System.out.println( rowObjects[i]);
}
}
// By now, we have itereated through all of the rows
inputStream.close();
}
catch( DBFException e) {
System.out.println( e.getMessage());
}
catch( IOException e) {
System.out.println( e.getMessage());
}
}
}
STEP 2: RUN IT ... :)
DOwnload link :http://www.java2s.com/Code/Jar/c/Downloadcomlinuxense10jar.htm
Step 2:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package jdbf;
/**
*
* @author saurabh-it
*/
import java.io.*;
import com.linuxense.javadbf.*;
public class JavaDBFReaderTest {
public static void main( String args[]) {
try {
// create a DBFReader object
//
InputStream inputStream = new FileInputStream("PATH_OF _UR_.DBF_FILE"); // take dbf file as program argument
DBFReader reader = new DBFReader( inputStream);
// get the field count if you want for some reasons like the following
//
int numberOfFields = reader.getFieldCount();
// use this count to fetch all field information
// if required
//
for( int i=0; i<numberOfFields; i++) {
DBFField field = reader.getField( i);
// do something with it if you want
// refer the JavaDoc API reference for more details
//
System.out.println( field.getName());
}
// Now, lets us start reading the rows
//
Object []rowObjects;
while( (rowObjects = reader.nextRecord()) != null) {
for( int i=0; i<rowObjects.length; i++) {
System.out.println( rowObjects[i]);
}
}
// By now, we have itereated through all of the rows
inputStream.close();
}
catch( DBFException e) {
System.out.println( e.getMessage());
}
catch( IOException e) {
System.out.println( e.getMessage());
}
}
}
STEP 2: RUN IT ... :)
No comments:
Post a Comment