• Post Reply Bookmark Topic Watch Topic
  • New Topic

different result being returned  RSS feed

 
dale conn
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

i have some code that works on my local pc, but when i put the code on a development server the code returns incorrect results

e.g.
String a = "folder1\folder2\folder3\abc.xml";
File file = new File(a);
System.out.println(file.getName());
System.out.println(file.getParentFile());

On my local PC i get
file.getName() = abc.xml
file.getParentFile() = folder1\folder2\folder3


On the developement sever i get
file.getName() = folder1\folder2\folder3\abc.xml
file.getParentFile() = null


Can anyone tell me why i'm not getting the correct result on the development server


thanks for any help
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try building your string in a platforn independant manner e.g.
Also use relative paths based on some property value, or the current directory instead of absolute paths.
[ June 29, 2006: Message edited by: Nigel Browne ]
 
dale conn
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't build my string as the value is taken from a database.

i bring the value back when i iterate through a recordset
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you'll need to modify it. Use String.replaceAll();
 
Vladimir Nesov
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With replaceAll it's decline to workd on original (Windows) system. It's better to create method which would create File object manually parsing path in known format.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!