aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DataInfo getValues() problem- see code 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 "DataInfo getValues() problem- see code" Watch "DataInfo getValues() problem- see code" New topic
Author

DataInfo getValues() problem- see code

Justin Wong
Greenhorn

Joined: Jul 31, 2001
Posts: 17
Hi,
This piece of code got me stumped for a whole day and I can't figure out why:
public class Project {

public static void main(String[] args) {
try {
Data x = new Data("c:\\temp\\scjd\\starting\\suncertify\\db\\db.db");

DataInfo[] r = x.criteriaFind("Origin airport='SFO',Destination airport='*'");

String [] values = r[1].getValues();
System.out.println(values[8]); // this prints out 22
if (values[8].equals("22"))
System.out.println("22");
else
System.out.println("not 22");

x.close();
} catch(DatabaseException ex) {
System.out.println(ex.toString());
} catch(IOException ex) {
System.out.println(ex.toString());
}
}
}

For some reason, it always prints out "not 22". Any input would be appreciated. Thanks
Matthew Comer
Ranch Hand

Joined: Aug 10, 2001
Posts: 37
The value probably has trailing spaces on it... Remember, this is a PRIMITIVE database - all coluumns are fixed width.
Try:
values[8].trim().equals...
Justin Wong
Greenhorn

Joined: Jul 31, 2001
Posts: 17
I just tried it and it works! Thanks a million.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DataInfo getValues() problem- see code