Solved

Java: file (path) naming conventions

Posted on 2006-06-29
7
576 Views
Last Modified: 2013-11-24
Currently, we are developing XSLT + Java servlets.
One question is on how to address a file (platform independent)?
What we tried (within XSL) is to address a file like that: file://///nameOfServer/.../... (with 5 slashes at the beginning).
That worked for MSIE and Firefox.

Now we address a file with the same naming convention as above and it will not work (dir.list(); = NULL).
Is there a naming convention that works on any platform (at least windows); file:///c:/temp doesn't work... And we tried many ;-)
0
Comment
Question by:go4java
  • 4
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17013854
file:// is a URL, so you cannot use it to create a File instance.
If you need a File then use a regular path, if you need a URL use what you cuurently using
File also has a method toURL() to convert File name to URL

> file:///c:/temp doesn't work...

try:

file:///c|/temp doesn't work...
0
 

Author Comment

by:go4java
ID: 17016179
We need a conversion rule from URL (file://///server/.../pdf/ => directory) to file naming, e.g. g:/.../pdf.
???
0
 
LVL 92

Expert Comment

by:objects
ID: 17016507
where is the url coming from?
and what do you need to do with the file?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:go4java
ID: 17016545
Well, actually the URL is a pre-defined path to all our web resources (htm, pdf...) and is been used within XSLT engine (to produce MSIE and Firefox compatible HTM pages).
We will run a batch process (Java + XSLT) to produce some 100 web pages (based on XML imput) and need to search files on our file server (by means of Java servlets). The result of such a search will be returned from Java servlet to XSL.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17017451
you should just need to take the protocol off the front of the url
and change first | to :

something like:

path = url.substring(8).replace('|', ':');
0
 

Author Comment

by:go4java
ID: 17018117
objects, could you pls. explain your rule on the URL given above:

file://///server/.../pdf/
0
 
LVL 92

Expert Comment

by:objects
ID: 17021421
you'll need different transformations depending on whether it contains a |
theres no standard way to do it as the url may not even point to a file.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question