jmri.util
Class FileUtil

java.lang.Object
  extended by jmri.util.FileUtil

public class FileUtil
extends Object

Common utility methods for working with Files.

We needed a place to refactor common File-processing idioms in JMRI code, so this class was created. It's more of a library of procedures than a real class, as (so far) all of the operations have needed no state information.

In particular, this is intended to provide Java 2 functionality on a Java 1.1.8 system, or at least try to fake it.

Author:
Bob Jacobsen Copyright 2003, 2005, 2006

Constructor Summary
FileUtil()
           
 
Method Summary
static String getExternalFilename(String pName)
          Find the resource file corresponding to a name.
static String getPortableFilename(File file)
          Convert a File object to our preferred storage form.
static String getPortableFilename(String filename)
          Convert a filename string to our preferred storage form.
static String getUrl(File file)
          Provide a URL for a given file.
static String getUrlViaUri(File file)
          Provide the URL for a particular file/directory via the URI form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

getExternalFilename

public static String getExternalFilename(String pName)
Find the resource file corresponding to a name. There are five cases: In any case, absolute pathnames will work.

Parameters:
pName - The name string, possibly starting with file: or resource:
Returns:
Absolute file name to use, or null.
Since:
2.7.2

getPortableFilename

public static String getPortableFilename(File file)
Convert a File object to our preferred storage form. This is the inverse of getExternalFilename(String pName). Deprecated forms are not created.

Parameters:
file - File to be represented
Since:
2.7.2

getPortableFilename

public static String getPortableFilename(String filename)
Convert a filename string to our preferred storage form. This is the inverse of getExternalFilename(String pName). Deprecated forms are not created.

Parameters:
filename - Filename to be represented
Since:
2.7.2

getUrlViaUri

public static String getUrlViaUri(File file)
Provide the URL for a particular file/directory via the URI form. Depending on the machine and context, either a true URL or a URI is needed to open a file. This method and getURL provide the two alternative ways to create th

Since:
1.7.3

getUrl

public static String getUrl(File file)
Provide a URL for a given file.

In version 1.7.2 and before, this would attempt to create the URL via the toURI() method of File. This is found to not work on all Windows PCs and JVMs. To enable the using code to do appropriate retries, this method doesn't use toURI(), and the FileUtil.getUrlViaUri() method does. To see an example of hos to use this, look at the XmlFIle class (which should be handling your XML I/O in any case).



Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads