aspose file tools*
The moose likes Java in General and the fly likes File constructor puts a forward slash in the constructed path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "File constructor puts a forward slash in the constructed path" Watch "File constructor puts a forward slash in the constructed path" New topic
Author

File constructor puts a forward slash in the constructed path

Kaverappa Prabhakar
Ranch Hand

Joined: Aug 18, 2009
Posts: 43
The java application with the following segment of code deployed on Tomcat running on Open VMS OS. The first line of code constucts pathname for the file inhous.properties. It blows up because it puts forward slash as shown in the System.out statement (second line of code)


In order to get around with the problem of forward slash I wrote the following code but I have not tested yet.


One other concern is that once the slash is blanked out, it will leave a blank space. Of course code can be written to remove the blank space.
QUESTION: Will the above code work in your opinion? If not, how to get make it work.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

This is how this File constructor is meant to work. It takes the parent path (Disk_5:[apache.jakarta.tomcat.conf]), appends the path separator (/ in this case), then the file name. I don't know OpenVMS but apparently the full path is Disk_5:[apache.jakarta.tomcat.conf]inhouse.properties. That means that you shouldn't use this file constructor but just do this:
In fact, this is exactly what you are already doing but without the additional steps.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Kaverappa Prabhakar
Ranch Hand

Joined: Aug 18, 2009
Posts: 43
Bob,

Thanks for the quick response and more so for suggested answer which eliminates extra lines of code. I tried your suggestion and it works. Java Ranch is the best website in not only resolving problems but also for learning from your suggestions/recomendations and references you provide to appropriate documents and books.

Thanks a lot,
Prabhakar
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

You're welcome, but it's Rob, not Bob
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: File constructor puts a forward slash in the constructed path