Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java: file (path) naming conventions

Posted on 2006-06-29
7
Medium Priority
?
604 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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