Hi, I'm new here and I wanted to contribute something, this is the basis of a java class I'm writing to read .dbc files from the filesystem, so far im quite sure it returns true values of string size, record size, field size and record count, I have only verified this using taliis to read the .dbc files, anyway I'm planning to contribute alt more but here it is for now
Code:
import java.io.*;
import java.lang.String;
import java.lang.Integer;
public class DBCFile
{
public DBCFile(String _filename)
{
File f = new File(_filename);
if(f.canRead())
filename = _filename;
else
error = true;
}
// Open database. It must be openened before it can be used.
public void open()
{
try
{
FileReader f = new FileReader(filename);
char[] hdr = new char[4];
char[] na = new char[4];
char[] nb = new char[4];
char[] es = new char[4];
char[] ss = new char[4];
f.read(hdr); // Number of records
assert(String.copyValueOf(hdr) == "WDBC");
header = String.copyValueOf(hdr);
f.read(na); // Number of record
recordCount = (na[0]) | (na[1]) | (na[2]) | (na[3]);
f.read(nb); // Number of fields
fieldCount = (nb[0]) | (nb[1]) | (nb[2]) | (nb[3]);
f.read(es); // Size of a record
recordSize = (es[0]) | (es[1]) | (es[2]) | (es[3]);
f.read(ss); // String size
stringSize = (ss[0]) | (ss[1]) | (ss[2]) | (ss[3]);
assert(fieldCount *4 == recordSize);
data = new char[recordSize * recordCount + stringSize];
stringTable = new char[(data.length) + recordSize * recordCount];
f.read(data);
/*
String tmp = "";
for(int i=1*recordSize+stringSize;i<stringSize;i++)
tmp += String.valueOf(data[i]);
System.out.println(tmp);
*/
f.close();
}
catch(IOException exc)
{
System.out.println("IOException"+exc.getMessage());
}
trace();// uncomment to hide debug info
}
private Boolean error = false;
public Boolean hasError(){
return error;
}
public void trace()
{
System.out.println("Traced output... header:"+header+" record count:"+recordCount+" field count:"+fieldCount+" record size:"+recordSize+" string size:"+stringSize+" error:"+hasError());
}
private String header;
private String filename;
private int recordSize;
private int recordCount;
private int fieldCount;
private int stringSize;
private char[] data;
private char stringTable[];
}