File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataInfo getValues() problem- see code

 
Justin Wong
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried it and it works! Thanks a million.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic