aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S  public int[] find(String[] criteria) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S  public int[] find(String[] criteria)" Watch "B&S  public int[] find(String[] criteria)" New topic
Author

B&S public int[] find(String[] criteria)

efoe akolly
Greenhorn

Joined: Jun 11, 2003
Posts: 17
I am planning to use the StringTokenizer to parse my database but since I have a binary file I don't know on which tokens I should parse a given record. When you create a StringTokenizer object you need to specify the token(s) on which a string is supposed to be broken like :
StringTokenizer mainStringTokenizer =
new StringTokenizer(searchCriteria, ",");
In my case I really don't know what to do.
Any suggestion will be very much appreciated.
Thanks
Dieskun Koper
Ranch Hand

Joined: Aug 15, 2004
Posts: 85
The StringTokenizer is a utility class to break up a string
that uses delimiters to separate the tokens.
Your database file has "no separators between fields". Therefore,
StringTokenizer is not appropiate.
efoe akolly
Greenhorn

Joined: Jun 11, 2003
Posts: 17
Thank you for your reply. I really appreciated it. In your opinion what other alternative can I use then.
Thanks
Dieskun Koper
Ranch Hand

Joined: Aug 15, 2004
Posts: 85
I'll tell you what I did and why if you tell me what alternatives you are considering and why.
efoe akolly
Greenhorn

Joined: Jun 11, 2003
Posts: 17
Well I am thinking about using regular expression but that also requires a split delimiter so I don't know anymore.
Dieskun Koper
Ranch Hand

Joined: Aug 15, 2004
Posts: 85
I read the file using DataInputStream's readByte and readFully methods. First the schema, with a for loop over the fields, then the records.
For single byte values I used readByte, for fields of which the size is known (or read from the schema), I used readFully.

I am not sure if there is a more flexible way that is less vulnerable to schema changes, that is why I wanted to hear your alternatives

Regards,
Dies
efoe akolly
Greenhorn

Joined: Jun 11, 2003
Posts: 17
Thanks Koper.
dennis du
Ranch Hand

Joined: Dec 31, 2004
Posts: 59
I am behind you. I used the RandomAccessFile class for the binary file too.

And I think this is the only way to do it according the database file sun provided. If you want to make it flexible,then don't set the read length contant,it is ok.


-------------------------------<br />OCP 9i <br />SCJP/SCJD/SCWCD(92%)/SCDJWS<br />XML(IBM Test 141)<br />Who is the next?SCBCD<br />SCBCD/CCNA/CCNP/PMP<br />not sure
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S public int[] find(String[] criteria)