Solved

Java: file (path) naming conventions

Posted on 2006-06-29
7
579 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web & database SERVERS -- PHYSICAL & VM ? 5 81
java example issue 5 44
Selenium docs api java index 3 67
netbeans can not run self signed app 8 12
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

733 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