java.io

Class File

Implemented Interfaces:
Comparable<T>, Serializable

public class File
extends Object
implements Serializable, Comparable<T>

An abstract representation of file and directory pathnames.

User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames. An abstract pathname has two components:

  1. An optional system-dependent prefix string, such as a disk-drive specifier, "/" for the UNIX root directory, or "\\\\" for a Microsoft Windows UNC pathname, and
  2. A sequence of zero or more string names.
Each name in an abstract pathname except for the last denotes a directory; the last name may denote either a directory or a file. The empty abstract pathname has no prefix and an empty name sequence.

The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an abstract pathname is converted into a pathname string, each name is separated from the next by a single copy of the default separator character. The default name-separator character is defined by the system property file.separator, and is made available in the public static fields separator and separatorChar of this class. When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system.

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

The prefix concept is used to handle root directories on UNIX platforms, and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, as follows:

Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change.

Since:
JDK1.0
See Also:
Serialized Form

Field Summary

static String
pathSeparator
The system-dependent path-separator character, represented as a string for convenience.
static char
pathSeparatorChar
The system-dependent path-separator character.
static String
separator
The system-dependent default name-separator character, represented as a string for convenience.
static char
separatorChar
The system-dependent default name-separator character.

Constructor Summary

File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.
File(String parent, String child)
Creates a new File instance from a parent pathname string and a child pathname string.
File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname.

Method Summary

boolean
canRead()
Tests whether the application can read the file denoted by this abstract pathname.
boolean
canWrite()
Tests whether the application can modify the file denoted by this abstract pathname.
int
compareTo(File pathname)
Compares two abstract pathnames lexicographically.
boolean
createNewFile()
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
static File
createTempFile(String prefix, String suffix)
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
static File
createTempFile(String prefix, String suffix, File directory)
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
boolean
delete()
Deletes the file or directory denoted by this abstract pathname.
void
deleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
boolean
equals(Object obj)
Tests this abstract pathname for equality with the given object.
boolean
exists()
Tests whether the file or directory denoted by this abstract pathname exists.
File
getAbsoluteFile()
Returns the absolute form of this abstract pathname.
String
getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.
File
getCanonicalFile()
Returns the canonical form of this abstract pathname.
String
getCanonicalPath()
Returns the canonical pathname string of this abstract pathname.
String
getName()
Returns the name of the file or directory denoted by this abstract pathname.
String
getParent()
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
File
getParentFile()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
String
getPath()
Converts this abstract pathname into a pathname string.
int
hashCode()
Computes a hash code for this abstract pathname.
boolean
isAbsolute()
Tests whether this abstract pathname is absolute.
boolean
isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.
boolean
isFile()
Tests whether the file denoted by this abstract pathname is a normal file.
boolean
isHidden()
Tests whether the file named by this abstract pathname is a hidden file.
long
lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.
long
length()
Returns the length of the file denoted by this abstract pathname.
String[]
list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
String[]
list(FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File[]
listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
File[]
listFiles(FileFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File[]
listFiles(FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
static File[]
listRoots()
List the available filesystem roots.
boolean
mkdir()
Creates the directory named by this abstract pathname.
boolean
mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
boolean
renameTo(File dest)
Renames the file denoted by this abstract pathname.
boolean
setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname.
boolean
setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed.
String
toString()
Returns the pathname string of this abstract pathname.
URI
toURI()
Constructs a file: URI that represents this abstract pathname.
URL
toURL()
Converts this abstract pathname into a file: URL.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

pathSeparator

public static final String pathSeparator
The system-dependent path-separator character, represented as a string for convenience. This string contains a single character, namely pathSeparatorChar.
Usages and Demos :

View More Examples of pathSeparator
   1: import gov.llnl.babel.Version;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:       StringTokenizer tok = new StringTokenizer(classpath, 
   6:                                                 File.pathSeparator);
   7:     
   8:         ...
   9:         if (path.endsWith(jarFileName)) {
  10:           File f = new File(path);
  11:           if (f.isFile()) {

View Full Code Here
   1:     public String getClasspath() {
   2:         return testProjectPath + File.pathSeparator +
   3:         ...
   4:             System.getProperty("sun.boot.class.path") + File.pathSeparator +  "../runtime/bin" +
   5:         ...
   6:             File.pathSeparator + System.getProperty("aspectjrt.path");    
   7:     }
   8:         ...
   9:     public Map getSourcePathResources() {
  10:         File srcBase = new File(getProjectSourcePath());

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:         args.add("../runtime/bin" 
   6:             + File.pathSeparator + System.getProperty("aspectjrt.path"));
   7:         
   8:         ...
   9:         args.add("../runtime/bin" 
  10:             + File.pathSeparator + System.getProperty("aspectjrt.path"));
  11:         
  12:         ...
  13:         
  14:         TestUtil.runMain("out" + File.pathSeparator + "out/lib.jar", "client.Client");

View Full Code Here
   1: import com.sun.enterprise.util.io.FileUtils;
   2: import java.io.File;
   3: 
   4:         ...
   5:         sInstallRoot = System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
   6:     sClasspath = sInstallRoot+File.separator+"lib"+File.separator+
   7:         ...
   8:                      "appserv-rt.jar"+File.pathSeparator+sInstallRoot+
   9:         ...
  10:                  File.separator+"lib"+File.separator+"admin-cli.jar";

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.net.URL;
   4:         ...
   5:     StringTokenizer st = new StringTokenizer(classpath,
   6:                          File.pathSeparator);
   7: 
   8:         ...
   9:     }
  10:     File pf = new File(policy);
  11:     if (!pf.exists()) {

View Full Code Here

pathSeparatorChar

public static final char pathSeparatorChar
The system-dependent path-separator character. This field is initialized to contain the first character of the value of the system property path.separator. This character is used to separate filenames in a sequence of files given as a path list. On UNIX systems, this character is ':'; on Microsoft Windows systems it is ';'.
Usages and Demos :

View More Examples of pathSeparatorChar
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.net.URLClassLoader;
   4:         ...
   5:             try {
   6:                 File f = new File(component);
   7:                 if (f.exists())
   8:         ...
   9:         for (int i=1; i < cnt; i++) {
  10:             cp.append(File.pathSeparatorChar);
  11:             cp.append( ((File)(_elements.elementAt(i))).getPath() );

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:             try {
   6:                 File f = new File(component);
   7:                 if (f.exists())
   8:         ...
   9:         for (int i=1; i < cnt; i++) {
  10:             cp.append(File.pathSeparatorChar);
  11:             cp.append( ((File)(_elements.elementAt(i))).getPath() );

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         if (classpath != null) {
   6:             String[] parts = classpath.split(new String(new char[] { File.pathSeparatorChar }));
   7:             StringBuffer effectiveClasspath = new StringBuffer();
   8:         ...
   9:                     } else {
  10:                         effectiveClasspath.append(File.pathSeparatorChar);
  11:                     }
  12:         ...
  13:                 } catch (MalformedURLException e1) {
  14:                     File path = new File(parts[x]);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.lang.annotation.Annotation;
   4:         ...
   5:             for (URL url : urlloader.getURLs()) {
   6:                 classpath.append(File.pathSeparatorChar);
   7:                 classpath.append(url.getFile());
   8:             }
   9:         }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         this.pathSeparator = pathSeparator;
   6:         this.pathSeparatorChar = pathSeparatorChar;
   7:     }
   8:         ...
   9: 
  10:     private static PlatformHelper localPlatform= new PlatformHelper(File.separator, File.separatorChar,
  11:         ...
  12:             File.pathSeparator, File.pathSeparatorChar);

View Full Code Here

separator

public static final String separator
The system-dependent default name-separator character, represented as a string for convenience. This string contains a single character, namely separatorChar.
Usages and Demos :

View More Examples of separator
   1: import java.io.ByteArrayInputStream;
   2: import java.io.File;
   3: import java.io.BufferedReader;
   4:         ...
   5:         
   6:             File file=new File("certs"+File.separator+"newcert.pem");
   7:             FileInputStream fis=new FileInputStream(file);
   8:         ...
   9:             String certDir=file.getParent();
  10:             file=new File(certDir+File.separator+"x509up_u0");
  11:             fis=new FileInputStream(file);

View Full Code Here
   1:             DefaultListModel listModel = tpDoc.getListModel();
   2:             File file = new File( "slidesdir" );
   3:             file.mkdir();
   4:         ...
   5:                 graph.paint(graphics);
   6:                 File f = new File( "slidesdir" + File.separator + "slide" + j + ".jpg" );
   7:                 f.deleteOnExit();
   8:                 ImageIO.write( img, "jpg", f );
   9:             }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         String applicationRoot = "test";
   6:         File testPath = new File(applicationRoot);
   7:         if (!testPath.exists())
   8:         ...
   9:         {
  10:             testPath = new File( "cps" + File.separator + applicationRoot);
  11:             if (testPath.exists())

View Full Code Here
   1: 
   2:        File target = new File(targetDir);
   3:        HashMap failedCopies = new HashMap();
   4:         ...
   5:           NamedNodeMap atts = node.getAttributes();
   6:           String file;
   7:           Node url = atts.getNamedItem("url");
   8:         ...
   9:            String s = (String) iterator.next();
  10:            File sourceFile = new File(".."+File.separator+"lib"+File.separator+s);
  11:         ...
  12:            File targetFile = new File(targetDir+File.separator+s);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:             if (log.isInfoEnabled()) {
   6:                 log.info("Specified configuration file: '" + configFile + "'");
   7:             }
   8:         ...
   9:             FileInputStream configXMLFile = new FileInputStream(new File(configFile));
  10: 
  11:         ...
  12:             if (home != null) {
  13:                 dbRoot = new File(home + File.separator + dbRoot).getCanonicalPath();

View Full Code Here

separatorChar

public static final char separatorChar
The system-dependent default name-separator character. This field is initialized to contain the first character of the value of the system property file.separator. On UNIX systems the value of this field is '/'; on Microsoft Windows systems it is '\\'.
Usages and Demos :

View More Examples of separatorChar
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:    private String findPropertyFile(String fn) {
   6:       File f = new File(fn);
   7:       if (f.canRead())
   8:         ...
   9:          return fn;
  10:       f = new File("cluster" + File.separatorChar + fn);
  11:       if (f.canRead())

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.util.ArrayList;
   4:         ...
   5:         final String directoryName = "../../src/java/com/gargoylesoftware/htmlunit/javascript/host";
   6:         final Set names = getFileNames(directoryName.replace('/', File.separatorChar));
   7: 
   8:         ...
   9:     private Set getFileNames( final String directoryName ) {
  10:         File directory = new File("."+File.separatorChar+directoryName);
  11:         if( directory.exists() == false ) {
  12:         ...
  13:             directory = new File("./src/java/".replace('/', File.separatorChar)+directoryName );

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:         List rootNodes = (List) mcrSession.get("rootNodes");
   6:         File[] contentTemplates = new File((CONFIG.getString("MCR.WCMS.templatePath") + "content/").replace('/', File.separatorChar)).listFiles();
   7:         Element rootOut = new Element("cms");
   8:         ...
   9:                             else if (action.equals("view") 
  10:                                     && (request.getParameter("file")!=null && !request.getParameter("file").equals(""))) {
  11:                                 
  12:         ...
  13:         try {
  14:             File logFile = new File(CONFIG.getString("MCR.WCMS.logFile").replace('/', File.separatorChar));

View Full Code Here
   1: import java.util.StringTokenizer;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     private String _classname = null;
   6:     private File _home_dir = null;
   7:     private String _mode = "jetty";
   8:         ...
   9: 
  10:     static File getDirectory(String name) {
  11:         try {
  12:         ...
  13:                             subject.startsWith("/")
  14:                                 ? (subject.replace('/', File.separatorChar))

View Full Code Here
   1:         {
   2:             File outFile = new File(outputfile);
   3:             pwOut = new PrintWriter( new BufferedWriter
   4:         ...
   5:                     pwOut.println("classpath: " + classpathString);
   6:                 StringTokenizer st = new StringTokenizer(classpathString, File.pathSeparator);
   7:                 int entries = st.countTokens();
   8:         ...
   9:                 {
  10:                     zipfile = new ZipFile(pathEntry.replace('/', File.separatorChar));
  11:                 }
  12:         ...
  13:                 {
  14:                     File file = new File((File)hash, className.replace('/', File.separatorChar));

View Full Code Here

Constructor Details

File

public File(File parent,
            String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.

If parent is null then the new File instance is created as if by invoking the single-argument File constructor on the given child pathname string.

Otherwise the parent abstract pathname is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty abstract pathname then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

Parameters:
parent - The parent abstract pathname
child - The child pathname string
Throws:
NullPointerException - If child is null
Usages and Demos :

View More Examples of File(File parent,String child)
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     protected void setUp() throws Exception {
   2:         File dir = new File(".", "propertyTestData" );
   3:         dir.mkdir();
   4:         ...
   5:                
   6:         File file = new File( dir ,"road.properties");
   7:         if( file.exists()){
   8:             file.delete();
   9:         }        

View Full Code Here

File

public File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.
Parameters:
pathname - A pathname string
Throws:
NullPointerException - If the pathname argument is null
Usages and Demos :

View More Examples of File(String pathname)
   1:     public void testWaitFor() {
   2:         FileUtils.waitFor(new File(""), -1);
   3:         ...
   4:         FileUtils.waitFor(new File(""), 2);
   5:     }
   6: 
   7: }

View Full Code Here
   1:         BasicMimeTypeProvider provider = new BasicMimeTypeProvider();
   2:         assertEquals("text/html", provider.getMimeType(new File(".html")));
   3:         ...
   4:         assertEquals("image/png", provider.getMimeType(new File(".png")));
   5:         ...
   6:         assertEquals("image/gif", provider.getMimeType(new File(".gif")));
   7:         assertEquals("application/octet-stream", provider.getMimeType(new File("foo")));

View Full Code Here
   1:             _fileChooser.setFileFilter(_filter);
   2:             _fileChooser.setSelectedFile(new File(""));
   3:             int result = _field.equals(_outfileField)
   4:                     ? _fileChooser.showSaveDialog(MainFrame.getInstance())
   5:                     : _fileChooser.showOpenDialog(MainFrame.getInstance());

View Full Code Here
   1:         TransformerFactory tfactory = TransformerFactory.newInstance();
   2:         tfactory.setURIResolver(new org.mmbase.util.xml.URIResolver(new java.io.File("")));
   3:         Transformer serializer = tfactory.newTransformer();
   4:         ...
   5:         if (!path.endsWith(File.separator)) path+=File.separator;
   6:         File bdir = new File(path);
   7:         if (bdir.isDirectory()) {
   8:             if (!bdir.getName().equals("builders")&&!bdir.getName().equals("applications")&&!bdir.getName().equals("tools")) {
   9:                 result+="<buildertype name=\""+bdir.getName()+"\"\n>";

View Full Code Here

File

public File(String parent,
            String child)
Creates a new File instance from a parent pathname string and a child pathname string.

If parent is null then the new File instance is created as if by invoking the single-argument File constructor on the given child pathname string.

Otherwise the parent pathname string is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty string then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

Parameters:
parent - The parent pathname string
child - The child pathname string
Throws:
NullPointerException - If child is null
Usages and Demos :

View More Examples of File(String parent,String child)
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     if(td == null || "".equals(td) ) {
   2:         testdir = new File(".", "testdata");
   3:     }
   4:         ...
   5:     else {
   6:         testdir = new File(td, "testdata");
   7:     }
   8:   }

View Full Code Here
   1:     protected void setUp() throws Exception {
   2:         File dir = new File(".", "propertyTestData" );
   3:         dir.mkdir();
   4:         ...
   5:                
   6:         File file = new File( dir ,"road.properties");
   7:         if( file.exists()){
   8:             file.delete();
   9:         }        

View Full Code Here

File

public File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname.

The exact form of a file: URI is system-dependent, hence the transformation performed by this constructor is also system-dependent.

For a given abstract pathname f it is guaranteed that

new File( f.toURI()).equals( f.getAbsoluteFile())
so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
Parameters:
uri - An absolute, hierarchical URI with a scheme equal to "file", a non-empty path component, and undefined authority, query, and fragment components
Throws:
NullPointerException - If uri is null
IllegalArgumentException - If the preconditions on the parameter do not hold
Since:
1.4
See Also:
toURI(), URI
Usages and Demos :

View More Examples of File(URI uri)
   1:     public void testWaitFor() {
   2:         FileUtils.waitFor(new File(""), -1);
   3:         ...
   4:         FileUtils.waitFor(new File(""), 2);
   5:     }
   6: 
   7: }

View Full Code Here
   1:         BasicMimeTypeProvider provider = new BasicMimeTypeProvider();
   2:         assertEquals("text/html", provider.getMimeType(new File(".html")));
   3:         ...
   4:         assertEquals("image/png", provider.getMimeType(new File(".png")));
   5:         ...
   6:         assertEquals("image/gif", provider.getMimeType(new File(".gif")));
   7:         assertEquals("application/octet-stream", provider.getMimeType(new File("foo")));

View Full Code Here
   1:             _fileChooser.setFileFilter(_filter);
   2:             _fileChooser.setSelectedFile(new File(""));
   3:             int result = _field.equals(_outfileField)
   4:                     ? _fileChooser.showSaveDialog(MainFrame.getInstance())
   5:                     : _fileChooser.showOpenDialog(MainFrame.getInstance());

View Full Code Here
   1:         TransformerFactory tfactory = TransformerFactory.newInstance();
   2:         tfactory.setURIResolver(new org.mmbase.util.xml.URIResolver(new java.io.File("")));
   3:         Transformer serializer = tfactory.newTransformer();
   4:         ...
   5:         if (!path.endsWith(File.separator)) path+=File.separator;
   6:         File bdir = new File(path);
   7:         if (bdir.isDirectory()) {
   8:             if (!bdir.getName().equals("builders")&&!bdir.getName().equals("applications")&&!bdir.getName().equals("tools")) {
   9:                 result+="<buildertype name=\""+bdir.getName()+"\"\n>";

View Full Code Here

Method Details

canRead

public boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.
Returns:
true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Usages and Demos :

View More Examples of canRead()
   1: 
   2:       File file = new File (args [0]);
   3: 
   4:         ...
   5:       System.out.println ("  Execute = "+file.canExecute ());
   6:       System.out.println ("  Read = "+file.canRead());
   7:       System.out.println ("  Write = "+file.canWrite ());
   8:    }
   9: }

View Full Code Here
   1:     {
   2:         System.out.println("Path Separator"+File.pathSeparator);
   3:         ...
   4:         System.out.println("Path Separator character"+File.pathSeparatorChar);
   5:         ...
   6:         System.out.println("Separator"+File.separator);
   7:         System.out.println("Separator character"+File.separatorChar);
   8:         ...
   9:         System.out.println(f);
  10:         System.out.println(f.canRead());

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private File file;
   7: 
   8:         ...
   9:     public boolean canRead() {
  10:         return file.canRead();
  11:     }

View Full Code Here
   1: {
   2:   private File file_;
   3: 
   4:         ...
   5:   SzilvaFileContents(File _file)
   6:   {
   7:         ...
   8:   {
   9:     return file_.canRead();
  10:   }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FilenameFilter;
   4:         ...
   5:             
   6:             File file;
   7:             try {
   8:         ...
   9:             File file = new File( uri.toURL().getFile() );
  10:             return file.isDirectory() && file.canRead() && containsPropertyFile( file );
  11:         }

View Full Code Here

canWrite

public boolean canWrite()
Tests whether the application can modify the file denoted by this abstract pathname.
Returns:
true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file; false otherwise.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method denies write access to the file
Usages and Demos :

View More Examples of canWrite()
   1: 
   2:       File file = new File (args [0]);
   3: 
   4:         ...
   5:       System.out.println ("  Read = "+file.canRead ());
   6:       System.out.println ("  Write = "+file.canWrite());
   7:    }
   8: }

View Full Code Here
   1:     {
   2:         System.out.println("Path Separator"+File.pathSeparator);
   3:         ...
   4:         System.out.println("Path Separator character"+File.pathSeparatorChar);
   5:         ...
   6:         System.out.println("Separator"+File.separator);
   7:         System.out.println("Separator character"+File.separatorChar);
   8:         ...
   9:         System.out.println(f.canRead());
  10:         System.out.println(f.canWrite());

View Full Code Here
   1: {
   2:   private File file_;
   3: 
   4:         ...
   5:   SzilvaFileContents(File _file)
   6:   {
   7:         ...
   8:   {
   9:     return file_.canWrite();
  10:   }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:   public StandaloneLocalFile(File file) {
   7:     if (file == null) {
   8:         ...
   9:   public boolean canWrite() throws IOException {
  10:     return file.canWrite();
  11:   }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.Serializable;
   4:         ...
   5:     
   6:     public boolean accept(File file) {
   7:         ...
   8:         return file.canWrite();
   9:     }

View Full Code Here

compareTo

public int compareTo(File pathname)
Compares two abstract pathnames lexicographically. The ordering defined by this method depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.
Parameters:
pathname - The abstract pathname to be compared to this abstract pathname
Returns:
Zero if the argument is equal to this abstract pathname, a value less than zero if this abstract pathname is lexicographically less than the argument, or a value greater than zero if this abstract pathname is lexicographically greater than the argument
Since:
1.2
Usages and Demos :

View More Examples of compareTo(File pathname)
   1: 
   2: import java.io.File;
   3: import java.io.Serializable;
   4:         ...
   5: 
   6: final class FileComparator implements Comparator<File>, Serializable {
   7:     static final long serialVersionUID = 879961226428880051L;
   8:         ...
   9: 
  10:     public int compare(File as, File bs) {
  11:         ...
  12:         return as.compareTo(bs);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.Serializable;
   4:         ...
   5:     public int compare(Object obj1, Object obj2) {
   6:         File file1 = (File)obj1;
   7:         File file2 = (File)obj2;
   8:         ...
   9:         return file1.compareTo(file2);
  10:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.util.Date;
   4:         ...
   5:             else {
   6:                 return ((String) m_object).compareTo((String) o.m_object);
   7:             }
   8:         ...
   9:         public int compareTo(DateCapsule o) {
  10:             return (m_date == null || o.m_date == null) ? 0 : m_date.compareTo(o.m_date);
  11:         }
  12:         ...
  13: 
  14:         private File m_file;

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     private static int compare(File file1, File file2) {
   7:     if (file1.isDirectory() && file2.isFile())
   8:         ...
   9:         return 1;
  10:     else return file1.compareTo(file2);
  11:     }
  12:         ...
  13:         item = (String) into.elementAt(idx) ;
  14:         cmp  = item.compareTo(key) ;

View Full Code Here
   1:     String string =
   2:         "{0} is a simple file browser that demonstrates flexible layout, drag and drop," +
   3:         "application launching, " + "mutithreading and in-line editing.";
   4:         ...
   5: 
   6: boolean isAncestor (File file1, File file2) {
   7:     while (file2 != null) {
   8:         ...
   9:     switch (index) {
  10:         case NAME_COLUMN: return file1.compareTo(file2);
  11:         case SIZE_COLUMN:

View Full Code Here

createNewFile

public boolean createNewFile()
            throws IOException
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

Returns:
true if the named file does not exist and was successfully created; false if the named file already exists
Throws:
IOException - If an I/O error occurred
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method denies write access to the file
Since:
1.2
Usages and Demos :

View More Examples of createNewFile()
   1: import java.io.File;
   2: import java.io.IOException;
   3:         ...
   4:     {
   5:       File f = new File( s );
   6: 
   7:         ...
   8:         {
   9:           f.createNewFile();
  10:           System.out.println( "create new file " + s );

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:             String fileName = Properties.getProperty(PropertiesHelper.DATA_FILE);
   6:             File dataFile = new File(fileName);
   7:             if (!dataFile.exists()) {
   8:         ...
   9:                 try {
  10:                     dataFile.createNewFile();
  11:                 } catch (IOException e) {

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.PrintStream;
   4:         ...
   5:     public static void mblLog(String text) {
   6:         File tmpFile = new File("E:\\idea-log.txt");
   7:         
   8:         ...
   9:             if ( !tmpFile.exists() )
  10:                 tmpFile.createNewFile();
  11:             

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class ListFilesInDirectoryTest extends TestCase {
   6:     private File[] expectedFiles =
   7:         ...
   8:         new File[] {
   9:             new File("c:/unittest/tmp/file1.xml"),
  10:         ...
  11:             File newFile = expectedFiles[i];
  12:             newFile.createNewFile();

View Full Code Here
   1:     {
   2:       File output = new File(dirName, fileName);
   3: 
   4:         ...
   5:     {
   6:       System.out.println("Error writing the file " + e);
   7:     }
   8:   }
   9: }

View Full Code Here

createTempFile

public static File createTempFile(String prefix,
                                  String suffix)
            throws IOException
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. Invoking this method is equivalent to invoking createTempFile(java.lang.String, java.lang.String, java.io.File) createTempFile(prefix, suffix, null).
Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
Returns:
An abstract pathname denoting a newly-created empty file
Throws:
IllegalArgumentException - If the prefix argument contains fewer than three characters
IOException - If a file could not be created
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method does not allow a file to be created
Since:
1.2
Usages and Demos :

View More Examples of createTempFile(String prefix,String suffix)
   1:   {
   2:     File tmpUnicodeFile =
   3:         ...
   4:       File.createTempFile("cztPrintTest", ".utf8");
   5:     tmpUnicodeFile.deleteOnExit();
   6:     Source source = new UrlSource(url);
   7:     Term term = ParseUtils.parse(new UrlSource(url), manager);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     private Document saveFile() throws IOException {
   6:         File tempFile = createTemporaryFile();
   7:         tempFile.deleteOnExit();
   8:         ...
   9: 
  10:     File createTemporaryFile() throws IOException {
  11:         ...
  12:         return File.createTempFile("_GanttProject_qSave", ".gan");

View Full Code Here
   1: 
   2:                 File tempFile = null;
   3:                 try {
   4:         ...
   5:                         File.createTempFile("numProc", "txt");
   6:                 }
   7:         ...
   8:                 catch(Exception  e) {
   9:                         System.err.println("Cannot create temp file");
  10:                         return -1;
  11:         ...
  12: 
  13:                 File tempFile = null;

View Full Code Here
   1: import java.awt.Color;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: implements ServiceContext {
   6:     private final File _homePath;
   7:     private final Properties _properties;
   8:         ...
   9:     
  10:     public WizardServiceContext(final File homePath, final Wizard wizard) {
  11:         _homePath = homePath;
  12:         ...
  13:     throws IOException {
  14:         return File.createTempFile(prefix, suffix);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:         super();
   6:         homeDir = aHomeDir + File.separator;
   7:         props = new Properties();
   8:         ...
   9:         try {
  10:             is = new FileInputStream(new File(homeDir, "WEB-INF/am2-config/amm.properties"));
  11:             props.load(is);
  12:         ...
  13:     throws IOException {
  14:         return File.createTempFile(prefix, suffix);

View Full Code Here

createTempFile

public static File createTempFile(String prefix,
                                  String suffix,
                                  File directory)
            throws IOException
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. If this method returns successfully then it is guaranteed that:
  1. The file denoted by the returned abstract pathname did not exist before this method was invoked, and
  2. Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
This method provides only part of a temporary-file facility. To arrange for a file created by this method to be deleted automatically, use the deleteOnExit() method.

The prefix argument must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "hjb" or "mail". The suffix argument may be null, in which case the suffix ".tmp" will be used.

To create the new file, the prefix and the suffix may first be adjusted to fit the limitations of the underlying platform. If the prefix is too long then it will be truncated, but its first three characters will always be preserved. If the suffix is too long then it too will be truncated, but if it begins with a period character ('.') then the period and the first three characters following it will always be preserved. Once these adjustments have been made the name of the new file will be generated by concatenating the prefix, five or more internally-generated characters, and the suffix.

If the directory argument is null then the system-dependent default temporary-file directory will be used. The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "C:\\WINNT\\TEMP". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the temporary directory used by this method.

Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
directory - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
Returns:
An abstract pathname denoting a newly-created empty file
Throws:
IllegalArgumentException - If the prefix argument contains fewer than three characters
IOException - If a file could not be created
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method does not allow a file to be created
Since:
1.2
Usages and Demos :

View More Examples of createTempFile(String prefix,String suffix,File directory)
   1: 
   2:     private File directory;
   3:     private long nextFileNumber;
   4:         ...
   5: 
   6:     public NumberFileCreator(File directory, long firstFileNumber) {
   7:     this.directory = directory;
   8:         ...
   9: 
  10:     File newLog() throws IOException {
  11:     File log = new File(directory, LOG_FORMAT.format(nextFileNumber));
  12:         ...
  13:     File newTempSnapshot() throws IOException {
  14:     return File.createTempFile("temp","generatingSnapshot",directory);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     private String srcDirName = FileUtilsTest.class.getName() + ".srcdir";
   6:     private File srcDirFile = null;
   7:     private String tgtDirName = FileUtilsTest.class.getName() + ".tgtdir";
   8:         ...
   9:     private File tgtDirFile = null;
  10:     
  11:         ...
  12:         for (int i = 0; i < howMany; i++) {
  13:             File.createTempFile(baseName, null, this.srcDirFile);

View Full Code Here
   1: import java.io.BufferedWriter;
   2: import java.io.File;
   3: import java.io.FileWriter;
   4:         ...
   5: 
   6:         File tempFile = File.createTempFile("CruiseControl", "TEST");
   7:         tempFile.deleteOnExit();
   8:         ...
   9:     
  10:             tempFile = File.createTempFile("CruiseControl", "TEST", tempDirectory);
  11:             writeContent(tempFile, "testing");
  12:         ...
  13:     
  14:             tempFile = File.createTempFile("CruiseControl", "TEST", tempDirectory);

View Full Code Here
   1: package de.uniwue.ki.util.file;
   2: 
   3:         ...
   4: 
   5:     private static File createNotExistingFile(File file, int depth, String tempPreffix, String tempSuffix)
   6:         throws IOException {
   7:         ...
   8:         } else if (depth > 1000) {
   9:             return File.createTempFile(tempPreffix, tempSuffix, file.getParentFile());

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:         assertEquals( "name", "com" +
   6:                               File.separatorChar +
   7:                               "biz" +
   8:         ...
   9:                               File.separatorChar +
  10:                               "Foo.class", name );
  11:         ...
  12:         final File dir =
  13:             File.createTempFile( "mgtest", ".tmp", baseDirectory )

View Full Code Here

delete

public boolean delete()
Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.
Returns:
true if and only if the file or directory is successfully deleted; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkDelete(String) method denies delete access to the file
Usages and Demos :

View More Examples of delete()
   1: import java.io.File;
   2: 
   3:         ...
   4: {
   5:   public static void deleteTree( File path )
   6:   {
   7:         ...
   8:     for ( File file : path.listFiles() )
   9:     {
  10:         ...
  11: 
  12:       file.delete();

View Full Code Here
   1: 
   2:         File bkup = new File("Delete.java~");
   3:         ...
   4:         bkup.delete();
   5:     }
   6: }

View Full Code Here
   1:                 for (Iterator it = fileToRaFile.keySet().iterator(); it.hasNext();) {
   2:                     final File file = (File)it.next();
   3:         ...
   4:                     final RandomAccessFile raFile = (RandomAccessFile)fileToRaFile.get(file);
   5: 
   6:         ...
   7:                         raFile.close();
   8:                         file.delete();
   9:                     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     private File tempDirectory;
   7: 
   8:         ...
   9: 
  10:     public File getTempDirectory() throws IOException {
  11:         if (tempDirectory == null) {
  12:         ...
  13:                     tempDirectory = File.createTempFile("q.sequence.line.", ".temp" + tries);
  14:                     tempDirectory.delete();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:   private File file;
   7:   private String mimeType;
   8:         ...
   9:   {
  10:   boolean result = file.delete();
  11:   }

View Full Code Here

deleteOnExit

public void deleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification.

Once deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

Throws:
SecurityException - If a security manager exists and its SecurityManager.checkDelete(String) method denies delete access to the file
Since:
1.2
See Also:
delete()
Usages and Demos :

View More Examples of deleteOnExit()
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     private File cacheEntry;
   7: 
   8:         ...
   9:         this.feed = feed;
  10:         this.cacheEntry = File.createTempFile("feed_"+feed.getUid(), "rss");
  11:         ...
  12:         cacheEntry.deleteOnExit();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileWriter;
   4:         ...
   5:         SchemaFactory schemaFactory =
   6:         File tmpFile = File.createTempFile("jaxpri","bug");
   7:         ...
   8:         tmpFile.deleteOnExit();
   9:         {

View Full Code Here
   1: {
   2:             File temp = File.createTempFile("jcl", ".out");
   3:         ...
   4:             temp.deleteOnExit();
   5:             long mod = temp.lastModified();
   6:             System.out.println(temp + ":" + mod);
   7:             try 

View Full Code Here
   1: 
   2:         File bkup = new File("Rename.java~");
   3:         ...
   4:         bkup.deleteOnExit();
   5: 
   6:         ...
   7: 
   8:         File tmp = File.createTempFile("foo", "tmp");
   9:         System.out.println("Your temp file is " + tmp.getCanonicalPath());
  10:         ...
  11:         tmp.deleteOnExit();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     public void test() throws Exception {
   6:         File tmp = File.createTempFile( "wfs", "xml" );
   7:         ...
   8:         tmp.deleteOnExit();
   9:         

View Full Code Here

equals

public boolean equals(Object obj)
Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is an abstract pathname that denotes the same file or directory as this abstract pathname. Whether or not two abstract pathnames are equal depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.
Overrides:
equals in interface Object
Parameters:
obj - The object to be compared with this abstract pathname
Returns:
true if and only if the objects are the same; false otherwise
Usages and Demos :

View More Examples of equals(Object obj)
   1: 
   2: import java.io.File;
   3: import javax.resource.spi.ConnectionRequestInfo;
   4:         ...
   5: public class JERequestInfo implements ConnectionRequestInfo {
   6:     private File rootDir;
   7:     private EnvironmentConfig envConfig;
   8:         ...
   9:    
  10:     public JERequestInfo(File rootDir,
  11:              EnvironmentConfig envConfig,
  12:         ...
  13:     JERequestInfo info = (JERequestInfo) obj;
  14:     return rootDir.equals(info.rootDir);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import org.apache.tools.ant.types.Resource;
   4:         ...
   5:     protected int resourceCompare(Resource foo, Resource bar) {
   6:         File foofile = ((FileResource) foo).getFile();
   7:         ...
   8:         File barfile = ((FileResource) bar).getFile();
   9:         ...
  10:         return foofile.equals(barfile) ? 0

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: public class SVGConverterFileSource implements SVGConverterSource {
   6:     File file;
   7:     String ref;
   8:         ...
   9:         String name = file.getName();
  10:         if (ref != null && !"".equals(ref)){
  11:             name += "#" + ref;
  12:         ...
  13:             String uri = file.toURL().toString();
  14:             if (ref != null && !"".equals(ref)){

View Full Code Here
   1: 
   2:     protected File        directory    = null;    
   3:     protected LocalNode   parent       = null;
   4:         ...
   5:         Vector infos = new Vector();
   6:         File[] files = directory.listFiles();
   7:         if (files == null) {
   8:         ...
   9:         files = new File[0];
  10:         }
  11:         ...
  12:     if (node instanceof LocalNode) {
  13:         return directory.equals(((LocalNode)node).directory);

View Full Code Here
   1: 
   2:   protected File file;
   3: 
   4:         ...
   5:   public OyoahaDirectoryComboBoxNode(File file, int depth)
   6:   {
   7:         ...
   8:     {
   9:       return file.equals(o);
  10:     }
  11:         ...
  12:       if(f!=null)
  13:       return file.equals(f);

View Full Code Here

exists

public boolean exists()
Tests whether the file or directory denoted by this abstract pathname exists.
Returns:
true if and only if the file or directory denoted by this abstract pathname exists; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file or directory
Usages and Demos :

View More Examples of exists()
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: import de.jose.util.xml.XMLUtil;
   6: import de.jose.util.file.FileUtil;
   7: import de.jose.util.StringUtil;
   8:         ...
   9:         this.config = config;
  10:         this.file = getFile();
  11:     }
  12:         ...
  13:         if (book!=null) return true;
  14:         if (!file.exists()) return false;

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.util.Stack;
   4:         ...
   5: {
   6:     private File mFile;
   7:     private Tool mDefaultTool = new SelectionTool();
   8:         ...
   9:     {
  10:         return mFile != null && mFile.exists() && !mFile.canWrite();
  11:     }
  12:         ...
  13: 
  14:     public void setFile(File file)

View Full Code Here
   1:     public void testNonExistentConfigFile() throws IOException {
   2:         File file = openFile("mumbleDoesNotExist.lst");
   3:         ...
   4:         assertTrue("valid non-existing file", !file.exists());
   5:         ...
   6:         BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath());
   7:         assertTrue("root: " + model.getRoot(), model.getRoot() != null);        

View Full Code Here
   1: import java.io.FileNotFoundException;
   2: import java.io.File;
   3: import java.io.InputStream;
   4:         ...
   5:       return null;
   6:     File file = new File(path);
   7:         ...
   8:     return file != null && file.exists() ? new FileInputStream(file) : null;
   9:   }

View Full Code Here
   1: package org.pf.file;
   2: 
   3:         ...
   4: import java.io.File;
   5: import java.net.URL;
   6:         ...
   7:   
   8:   public static File findFileOnClasspath( String filename ) 
   9:   {
  10:         ...
  11:                 FileLocator locator = FileLocator.create( file ) ;
  12:                 success = locator.exists() ;

View Full Code Here

getAbsoluteFile

public File getAbsoluteFile()
Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath()()).
Returns:
The absolute abstract pathname denoting the same file or directory as this abstract pathname
Throws:
SecurityException - If a required system property value cannot be accessed.
Since:
1.2
Usages and Demos :

View More Examples of getAbsoluteFile()
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     public FileMemberSource(final File f) throws IOException {
   7:         LineNumberReader reader = new LineNumberReader(new InputStreamReader(
   8:         ...
   9: 
  10:                     File file = new File(name.trim());
  11:                     if (!file.isAbsolute()) {
  12:         ...
  13:                         file = new File(f.getAbsoluteFile().getParentFile()

View Full Code Here
   1: import java.io.BufferedInputStream ;
   2: import java.io.File ;
   3: import java.io.FileInputStream ;
   4:         ...
   5: 
   6:     final public static File getCanonicalFile (File file) {
   7:     try {
   8:         ...
   9:     } catch (IOException exception) {
  10:         return file.getAbsoluteFile() ;
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.StringReader;
   4:         ...
   5: 
   6:         File f = TestUtils.getResourceFile("lib/xml/schemas/ccverificationrdf-schema.rng");
   7:         parser.setProperty(
   8:         ...
   9:                 f.getAbsoluteFile().toURI());
  10:         parser.parse(new InputSource(new StringReader(rdf)));

View Full Code Here
   1: import java.io.BufferedReader;
   2: import java.io.File;
   3: import java.io.FileReader;
   4:         ...
   5:     
   6:     File workDir = new File(System.getProperty("benchmark.work.dir","work"));
   7:     assertTrue("Bad workDir: "+workDir, workDir.exists()&& workDir.isDirectory());
   8:         ...
   9:     File srcTestDir = new File(new File(new File(new File(new File(
  10:       new File(new File(workDir.getAbsoluteFile().getParentFile(),
  11:         "src"),"test"),"org"),"apache"),"lucene"),"benchmark"),"quality");

View Full Code Here
   1: import java.awt.image.BufferedImage;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:     try {
   6:       ImageIO.write(img, fileType.toLowerCase(), new File(fullFileName));
   7:     } catch (IOException ioe) {
   8:         ...
   9:     
  10:     File tempFile = 
  11:       new File(new File(System.getProperty("user.dir")), 
  12:         ...
  13:       NetPrintUtilities.toPNGfile(graph, 5, tempFile.getAbsolutePath());
  14:       FileInputStream fis = new FileInputStream(tempFile.getAbsoluteFile());

View Full Code Here

getAbsolutePath

public String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.

If this abstract pathname is already absolute, then the pathname string is simply returned as if by the getPath() method. If this abstract pathname is the empty abstract pathname then the pathname string of the current user directory, which is named by the system property user.dir, is returned. Otherwise this pathname is resolved in a system-dependent way. On UNIX systems, a relative pathname is made absolute by resolving it against the current user directory. On Microsoft Windows systems, a relative pathname is made absolute by resolving it against the current directory of the drive named by the pathname, if any; if not, it is resolved against the current user directory.

Returns:
The absolute pathname string denoting the same file or directory as this abstract pathname
Throws:
SecurityException - If a required system property value cannot be accessed.
See Also:
isAbsolute()
Usages and Demos :

View More Examples of getAbsolutePath()
   1:       try {
   2:          File file = new File("metadata.xml");
   3:          fw = new FileWriter(file);
   4:         ...
   5:          System.out.println("Writing db data to file " + file.getAbsolutePath());
   6:          webRS.writeXml(fw);
   7: 
   8:          StringWriter sw = new StringWriter();

View Full Code Here
   1:       try {
   2:          File file = new File(id + ".xml");
   3:          fw = new FileWriter(file);
   4:         ...
   5:          System.out.println("Writing db data to file " + file.getAbsolutePath());
   6:          webRS.writeXml(fw);
   7: 
   8:          StringWriter sw = new StringWriter();

View Full Code Here
   1:     
   2:     private File file = null;
   3: 
   4:         ...
   5: 
   6:     public HelpProperties(String name, File dir) {
   7:         super();
   8:         this.name = name;
   9:         file = new File(dir, name);

View Full Code Here
   1: import java.io.BufferedWriter;
   2: import java.io.File;
   3: import java.io.FileWriter;
   4:         ...
   5:     
   6:     public static void export( JTree tree, String type, File file, SwoopModel swModel )
   7:     {
   8:         ...
   9:         {
  10:             System.out.println("Exporting to file " + file.getAbsolutePath() + "...");
  11:             BufferedWriter writer = new BufferedWriter( new FileWriter( file ) );

View Full Code Here
   1: 
   2:     public static boolean isJarFile(File file) throws DeploymentException {
   3:         ...
   4:         if(file.isDirectory()) {
   5:             return false;
   6:         ...
   7:         if(!file.canRead()) {
   8:             throw new DeploymentException("Cannot read file "+file.getAbsolutePath());
   9:         }
  10:         ...
  11:         } catch(IOException e) {
  12:             throw new DeploymentException("Cannot read from file "+file.getAbsolutePath(), e);

View Full Code Here

getCanonicalFile

public File getCanonicalFile()
            throws IOException
Returns the canonical form of this abstract pathname. Equivalent to new File(this.getCanonicalPath()()).
Returns:
The canonical pathname string denoting the same file or directory as this abstract pathname
Throws:
IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries
SecurityException - If a required system property value cannot be accessed, or if a security manager exists and its java.lang.SecurityManager.checkRead method denies read access to the file
Since:
1.2
Usages and Demos :

View More Examples of getCanonicalFile()
   1: import java.io.BufferedInputStream ;
   2: import java.io.File ;
   3: import java.io.FileInputStream ;
   4:         ...
   5: 
   6:     final public static File getCanonicalFile (File file) {
   7:     try {
   8:         ...
   9:         return file.getCanonicalFile() ;
  10:     } catch (IOException exception) {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.io.FilenameFilter;
   4:         ...
   5: 
   6:     private File getDirectory(String dir) 
   7:         throws BootstrapException {
   8:         ...
   9:         File baseDir = new File(dir);
  10:         if (!baseDir.exists() || 
  11:         ...
  12:         try {
  13:             return baseDir.getCanonicalFile();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     
   6:     public boolean recycle(File file) throws IOException, SecurityException {
   7:         throw new UnsupportedOperationException("Your platform doesn't support this method");
   8:         ...
   9:         if (file.isFile()) {
  10:             freeSpace = new BigInteger(Long.toString(this.getFreeSpace(file.getCanonicalFile().getParent())));
  11:             return freeSpace; 
  12:         ...
  13:         if (file.isFile()) {
  14:             totalSpace = new BigInteger(Long.toString(this.getTotalSpace(file.getCanonicalFile().getParent())));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     
   6:     public boolean recycle(File file) throws IOException, SecurityException {
   7:         throw new UnsupportedOperationException("Your platform doesn't support this method");
   8:         ...
   9:         if (file.isFile()) {
  10:             freeSpace = new BigInteger(Long.toString(this.getFreeSpace(file.getCanonicalFile().getParent())));
  11:             return freeSpace; 
  12:         ...
  13:         if (file.isFile()) {
  14:             totalSpace = new BigInteger(Long.toString(this.getTotalSpace(file.getCanonicalFile().getParent())));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     
   6:     public boolean recycle(File file) throws IOException,
   7:             SecurityException {
   8:         ...
   9:         if (file.isFile()) {
  10:             freeSpace = new BigInteger(Long.toString(this.getFreeSpace(file.getCanonicalFile().getParent())));
  11:             return freeSpace; 
  12:         ...
  13:         if (file.isFile()) {
  14:             totalSpace = new BigInteger(Long.toString(this.getTotalSpace(file.getCanonicalFile().getParent())));

View Full Code Here

getCanonicalPath

public String getCanonicalPath()
            throws IOException
Returns the canonical pathname string of this abstract pathname.

A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent. This method first converts this pathname to absolute form if necessary, as if by invoking the getAbsolutePath() method, and then maps it to its unique form in a system-dependent way. This typically involves removing redundant names such as "." and ".." from the pathname, resolving symbolic links (on UNIX platforms), and converting drive letters to a standard case (on Microsoft Windows platforms).

Every pathname that denotes an existing file or directory has a unique canonical form. Every pathname that denotes a nonexistent file or directory also has a unique canonical form. The canonical form of the pathname of a nonexistent file or directory may be different from the canonical form of the same pathname after the file or directory is created. Similarly, the canonical form of the pathname of an existing file or directory may be different from the canonical form of the same pathname after the file or directory is deleted.

Returns:
The canonical pathname string denoting the same file or directory as this abstract pathname
Throws:
IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries
SecurityException - If a required system property value cannot be accessed, or if a security manager exists and its java.lang.SecurityManager.checkRead method denies read access to the file
Since:
JDK1.1
Usages and Demos :

View More Examples of getCanonicalPath()
   1: import java.io.DataInputStream;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:         if (nargs == 1){
   6:             File file = null;
   7:             Object arg = args[0];
   8:         ...
   9:                 try {
  10:                     return new File(file.getCanonicalPath());
  11:                 } catch (IOException e){

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FilenameFilter;
   4:         ...
   5:    {
   6:       File[] baseFiles = null;
   7:         ...
   8:       File[] endFiles = null;
   9:       String response = "";
  10:         ...
  11:          File tmpDir = serverConfig.getServerTempDir();
  12:          tmpDir = new File(tmpDir.getCanonicalPath() + "/jbossws");

View Full Code Here
   1: import org.exoplatform.services.jcr.util.PathUtil;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:   public NodeContainer resolve(File rootFile, String jcrPath) throws PathNotFoundException,
   7:       RepositoryException, IOException {
   8:         ...
   9:     int i = 0;
  10:     File container = null;
  11:     String parentType = "nt:folder";
  12:         ...
  13:       ancestor = PathUtil.getAncestorPath(jcrPath, i);
  14:       container = new File(rootFile.getCanonicalPath() + ancestor);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5: import org.jboss.logging.Logger;
   6: import org.jboss.util.file.JarUtils;
   7: import org.jboss.ws.core.server.UnifiedDeploymentInfo;
   8:         ...
   9: 
  10:    public URL process(URL warURL, File destDir, String servletName) throws IOException
  11:    {
  12:         ...
  13: 
  14:       File outFile = new File(destDir.getCanonicalPath() + "/" + warName);

View Full Code Here
   1:             ClassRepository cp = (ClassRepository) e.nextElement();
   2:             File f = cp.getFile();
   3:             if (cpath.length()>0) cpath += separator;
   4:         ...
   5: 
   6:     public void addRepository( File f, Object pd ) {
   7:     try {
   8:         ...
   9:             classP.addElement(
  10:                 new ClassRepository( new File(FileUtil.patch(f.getCanonicalPath())), pd )
  11:                 );

View Full Code Here

getName

public String getName()
Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.
Returns:
The name of the file or directory denoted by this abstract pathname, or the empty string if this pathname's name sequence is empty
Usages and Demos :

View More Examples of getName()
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class FilenameEndsWithDotTractRecognizer implements TractRecognizer {
   6:     public boolean isTract(File file) {
   7:         ...
   8:         return file != null && file.getName().endsWith(".tract");
   9:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     private File file;
   7: 
   8:         ...
   9:         return (free ? "free" : "busy") + " slot with " + readers
  10:                 + " reader(s) on file " + file.getName();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileWriter;
   4:         ...
   5: public class FileStream {
   6:    File file;
   7:    FileWriter fw;
   8:         ...
   9:       } catch (Exception e) {
  10:          throw new Error("error writing to file " + file.getName() +
  11:                          "\n" + e.toString());
  12:         ...
  13:       } catch (Exception e) {
  14:          throw new Error("unable to close file " + file.getName() +

View Full Code Here
   1:       try {
   2:           File file = new File(inFile);
   3: 
   4:         ...
   5:               if (offset < bytes.length) {
   6:                   throw new IOException("Could not completely read file "+file.getName());
   7:               }
   8: 
   9:               is.close();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     public void run(final File[] exportFiles, final GanttOptions options, UIFacade uiFacade) {
   7:         IJobManager jobManager = Platform.getJobManager();
   8:         ...
   9: 
  10:     private Job createTransferJob(URL baseUrl, final File file) throws IOException {
  11:         ...
  12:         final URL outUrl = new URL(baseUrl, file.getName());

View Full Code Here

getParent

public String getParent()
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.

The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

Returns:
The pathname string of the parent directory named by this abstract pathname, or null if this pathname does not name a parent
Usages and Demos :

View More Examples of getParent()
   1:     void notifyEntry(String filename, int status) {
   2:     File         file  = new File(cvs.getDirectory(), filename);
   3:         ...
   4:     File         dir   = new File(file.getParent());
   5:     String       name  = file.getName();
   6:     CvsDirectory child = null;
   7:     try {

View Full Code Here
   1: import java.io.File;
   2: import java.io.FileOutputStream;
   3:         ...
   4:       System.out.println("The path " + aFile.getPath()
   5:                          + " does not specify a file. Program aborted.");
   6:       System.exit(1);
   7:         ...
   8:       aFile = aFile.getAbsoluteFile();
   9:       File parentDir = new File(aFile.getParent());
  10:         parentDir.mkdirs();

View Full Code Here
   1: import pnuts.lang.Context;
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     static boolean isRelative(File file){
   7:         return !file.isAbsolute() && file.getPath().charAt(0) != File.separatorChar;
   8:         ...
   9:     public static boolean ensureBaseDirectory(File file){
  10:         File dir = new File(file.getParent());
  11:         if (!dir.exists()){

View Full Code Here
   1: import java.util.jar.JarInputStream;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:         }
   6:         File f = new File(fileName);
   7:         if(!f.exists()) {
   8:         ...
   9:     } else {
  10:         if (f.getParent() != null) {
  11:         ...
  12:         File d = new File(f.getParent());

View Full Code Here
   1: 
   2:   public DebugOyoahaTheme(DebugOyoahaConsole _debug, File _file)
   3:   {
   4:         ...
   5:     {
   6:       loader = new OyoahaFileThemeLoader(_debug, getClass().getClassLoader(), new File(_file.getParent()));
   7:     }
   8:   }

View Full Code Here

getParentFile

public File getParentFile()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.

The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

Returns:
The abstract pathname of the parent directory named by this abstract pathname, or null if this pathname does not name a parent
Since:
1.2
Usages and Demos :

View More Examples of getParentFile()
   1:     private static ClassLoader toolsClassLoader() {
   2:     File javaHome   = new File(System.getProperty("java.home"));
   3:         ...
   4:     File classesDir = new File(javaHome, "classes");
   5:         ...
   6:     File libDir     = new File(javaHome.getParentFile(), "lib");
   7:     File toolsJar   = new File(libDir, "tools.jar");

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         
   6:         File tmpFile = File.createTempFile("prefix", "postfix");
   7:         tmpFile.deleteOnExit();
   8:         ...
   9:         File dir = new File(tmpFile.getParentFile(), "subdir");
  10:         dir.mkdir();
  11:         ...
  12:         tmpFile.deleteOnExit();
  13:         File dir = new File(tmpFile.getParentFile(), "subdir");

View Full Code Here
   1: import java.io.BufferedWriter;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:     private File infile;
   7: 
   8:         ...
   9:     public RegExpHelper(String infile) {
  10:         this.infile = new File(infile);
  11:     }
  12:         ...
  13:     private void escapeFile() throws IOException {
  14:         File outFile = new File(infile.getParentFile(), "build.golden.regexp");

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:         
   6:         File f = new File(platformXML.getFile());
   7: 
   8:         try {
   9:             if (!f.exists()) {

View Full Code Here
   1:     private Map<String, Setting> settingMap;
   2:     private File prefFile;
   3:     private Properties valueProperties;
   4:         ...
   5:     
   6:     public Preferences( File file )
   7:     {
   8:         ...
   9:             }
  10:             File bakFile = new File( prefFile.getParentFile(),
  11:                 prefFile.getName() + ".bak" );
  12:         ...
  13:         
  14:         File bakFile = new File( prefFile.getParentFile(), prefFile.getName() + ".bak" );

View Full Code Here

getPath

public String getPath()
Converts this abstract pathname into a pathname string. The resulting string uses the default name-separator character to separate the names in the name sequence.
Returns:
The string form of this abstract pathname
Usages and Demos :

View More Examples of getPath()
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     public void setLastFile(File file, WorkbenchContext context) {
   7:         ApplicationOptionsPlugIn.options(context).put(getLastFilenameKey(),
   8:         ...
   9:                 file != null ? file.getPath() : null);
  10:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     public boolean accept(File f) {
   7:         ...
   8:         return f != null && f.isFile() && accept(f.getPath());
   9:     }
  10:         ...
  11: 
  12:         String path = purl.getPath();

View Full Code Here
   1:         } else if (argv.length == 2) {
   2:             File file = new File(argv[0]);
   3:             if (!file.exists()) {
   4:         ...
   5:                 System.err.println("can't convert non existing file" + file.getPath());
   6:             }
   7:             File out = new File(argv[1]);
   8:             InputStream in = new IECompatibleJpegInputStream(new FileInputStream(file));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileNotFoundException;
   4:         ...
   5:     {
   6:         File strutsConfigFile = null;
   7:         
   8:         ...
   9:             getDiagnostics().addError( publicClass, "error.could-not-generate",
  10:                     strutsConfigFile != null ? strutsConfigFile.getPath() : null,
  11:                     e.getMessage() );
  12:         ...
  13:             getDiagnostics().addError( publicClass, "error.could-not-generate",
  14:                     strutsConfigFile != null ? strutsConfigFile.getPath() : null,

View Full Code Here
   1: import java.io.DataOutputStream;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:                 if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
   6:                     IPath path = entry.getPath();
   7:                     if (externalTimeStamps.get(path) == null) {
   8:         ...
   9:                         Object target = JavaModel.getTarget(wRoot, path, true);
  10:                         if (target instanceof java.io.File) {
  11:         ...
  12:                             long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);

View Full Code Here

hashCode

public int hashCode()
Computes a hash code for this abstract pathname. Because equality of abstract pathnames is inherently system-dependent, so is the computation of their hash codes. On UNIX systems, the hash code of an abstract pathname is equal to the exclusive or of the hash code of its pathname string and the decimal value 1234321. On Microsoft Windows systems, the hash code is equal to the exclusive or of the hash code of its pathname string converted to lower case and the decimal value 1234321.
Overrides:
hashCode in interface Object
Returns:
A hash code for this abstract pathname
Usages and Demos :

View More Examples of hashCode()
   1: 
   2: import java.io.File;
   3: import javax.resource.spi.ConnectionRequestInfo;
   4:         ...
   5: public class JERequestInfo implements ConnectionRequestInfo {
   6:     private File rootDir;
   7:     private EnvironmentConfig envConfig;
   8:         ...
   9:    
  10:     public JERequestInfo(File rootDir,
  11:              EnvironmentConfig envConfig,
  12:         ...
  13:     public int hashCode() {
  14:     return rootDir.hashCode();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: {
   6:     File xslFile;
   7:         ...
   8:     File targetDirectory;
   9: 
  10:         ...
  11:     public int hashCode() {
  12:         return xslFile.hashCode();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: {
   6:     protected File systemFile;
   7:     
   8:         ...
   9:     public SharedResource( File file )
  10:     {
  11:         ...
  12:     {
  13:         return systemFile.hashCode();

View Full Code Here
   1: import com.u2d.model.*;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:    }
   6:    protected File _value;
   7:    protected FileUseIntent _intent = FileUseIntent.OPEN;
   8:         ...
   9:    public FileEO() {}
  10:    public FileEO(File value) { _value = value; }
  11:    public FileEO(String value) { this(new File(value)); }
  12:         ...
  13: 
  14:    public int hashCode() { return _value.hashCode(); }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     StreamKey(File file, StreamType type) {
   7:         if (file == null || type == null)
   8:             throw new IllegalArgumentException("Cannot use <null> for " + 
   9:                 "path or type arguments.");

View Full Code Here

isAbsolute

public boolean isAbsolute()
Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\".
Returns:
true if this abstract pathname is absolute, false otherwise
Usages and Demos :

View More Examples of isAbsolute()
   1: import pnuts.lang.Context;
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     static boolean isRelative(File file){
   7:         ...
   8:         return !file.isAbsolute() && file.getPath().charAt(0) != File.separatorChar;
   9:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.InputStream;
   4:         ...
   5: public class FileFileIO extends sun.io.FileIO {
   6:     File file;
   7:     protected FileFileIO(String path) {
   8:         ...
   9:     public boolean isAbsolute() {
  10:         return file.isAbsolute();
  11:     }

View Full Code Here
   1:             catch (SecurityException se) {
   2:                 return "file:" + localPath;
   3:             }
   4:         ...
   5:         if (null != absolutePath) {
   6:             urlString = absolutePath.startsWith(File.separator) ?
   7:         }
   8:         ...
   9:         else {
  10:             urlString = "file:" + localPath;
  11:         }
  12:         ...
  13:         final File file = new File(systemId);
  14:         return file.isAbsolute();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:             return false;
   6:          File test = new File(path.trim());
   7:         ...
   8:          return test.isAbsolute();
   9:       }

View Full Code Here
   1: import java.awt.event.WindowEvent;
   2: import java.io.File;
   3: import java.net.URI;
   4:         ...
   5:             
   6:             File file = new File(userText);
   7:             if (isFileSystemPath(file)) {
   8:         ...
   9:     private static boolean isFileSystemPath(File file) {
  10:         return file.isAbsolute();
  11:     }

View Full Code Here

isDirectory

public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.
Returns:
true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Usages and Demos :

View More Examples of isDirectory()
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     public boolean accept(File f) {
   7:         ...
   8:         return f.getName().toLowerCase().endsWith(".pdf") || f.isDirectory();
   9:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         try {
   6:             File f;
   7:             String indexFile = System.getProperty(CaTIES_INDEX_DIRECTORY);
   8:         ...
   9:             boolean createDirectory = true;
  10:             if ((f = new File(indexFile)).exists() && f.isDirectory()) {
  11:                 createDirectory = false;

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileFilter;
   4:         ...
   5:         return new FileFilter() {
   6:             public boolean accept(File pathname) {
   7:                 return pathname.getName().startsWith(_prefix);
   8:         ...
   9:         return new FileFilter() {
  10:             public boolean accept(File pathname) {
  11:                 return pathname.getName().endsWith(_suffix);
  12:         ...
  13:             public boolean accept(File pathname) {
  14:                 return pathname.exists() && pathname.isDirectory();

View Full Code Here
   1:       if (System.getProperty("java.util.logging.config.class") == null
   2:          && System.getProperty("java.util.logging.config.file") == null)
   3:       {
   4:         ...
   5:             Logger.getLogger("com.horstmann.corejava").log(Level.SEVERE, 
   6:                "Can't create log file handler", e);
   7:          }
   8:         ...
   9: 
  10:       JMenu menu = new JMenu("File");
  11:       menuBar.add(menu);
  12:         ...
  13:                {
  14:                   return f.getName().toLowerCase().endsWith(".gif") || f.isDirectory();

View Full Code Here
   1: 
   2:       JMenu menu = new JMenu("File");
   3:       menuBar.add(menu);
   4:         ...
   5:       JFileChooser chooser = new JFileChooser();
   6:       chooser.setCurrentDirectory(new File("."));
   7:       
   8:         ...
   9:          {
  10:             public boolean accept(File f)
  11:             {
  12:         ...
  13:                return f.getName().toLowerCase().endsWith(".gif") || f.isDirectory();

View Full Code Here

isFile

public boolean isFile()
Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
Returns:
true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Usages and Demos :

View More Examples of isFile()
   1: 
   2: import java.io.File;
   3: import java.io.FileFilter;
   4:         ...
   5: 
   6:             public boolean accept(File file) {
   7: 
   8:         ...
   9:                 return file.isFile() && (file.getName().endsWith(".html") || file.getName().endsWith(".htm"));
  10:             }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileFilter;
   4:         ...
   5:    public boolean accept(
   6:       File flPathName
   7:    )
   8:         ...
   9:    {
  10:       return flPathName.isFile()
  11:              &&  flPathName.getName().toLowerCase().endsWith(m_strExtension);

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     public boolean accept(File f) {
   7:         ...
   8:         return f != null && f.isFile() && accept(f.getPath());
   9:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import javax.swing.filechooser.FileFilter;
   4:         ...
   5: {
   6:     public boolean accept(File file)
   7:     {
   8:         ...
   9:         if (
  10:             file.isFile() &&
  11:                 (name.endsWith(".zip")))

View Full Code Here
   1: 
   2: import java.io.File;
   3: import javax.swing.filechooser.FileFilter;
   4:         ...
   5: {
   6:     public boolean accept(File file)
   7:     {
   8:         ...
   9:         if (
  10:             file.isFile() &&
  11:                 (name.endsWith(".ftl")))

View Full Code Here

isHidden

public boolean isHidden()
Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.
Returns:
true if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Since:
1.2
Usages and Demos :

View More Examples of isHidden()
   1: 
   2: import java.io.File;
   3: import java.io.Serializable;
   4:         ...
   5:     
   6:     public boolean accept(File file) {
   7:         ...
   8:         return file.isHidden();
   9:     }

View Full Code Here
   1: 
   2: package jaxlib.io.file.filter;
   3: 
   4:         ...
   5: import java.io.File;
   6: import java.io.FileFilter;
   7:         ...
   8: 
   9: import jaxlib.io.file.Files;
  10: 
  11:         ...
  12:       case WRITABLE     : return f.canWrite();
  13:       case HIDDEN       : return f.isHidden();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private File file;
   7: 
   8:         ...
   9:     {
  10:         return file.isHidden();
  11:     }

View Full Code Here
   1: public class LocalFile extends FileStore {
   2:     protected final File file;
   3:     protected final String filePath;
   4:         ...
   5: 
   6:     private static int attributes(File aFile) {
   7:         if (!aFile.exists() || aFile.canWrite())
   8:         ...
   9:         info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, file.exists() && !file.canWrite());
  10:         info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden());
  11:         return info;

View Full Code Here

lastModified

public long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.
Returns:
A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Usages and Demos :

View More Examples of lastModified()
   1: package fr.jayasoft.ivy.repository.file;
   2: 
   3:         ...
   4: import java.io.File;
   5: 
   6:         ...
   7: public class FileResource implements Resource {
   8:     private File _file;
   9: 
  10:         ...
  11:     public long getLastModified() {
  12:         return _file.lastModified();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     private java.lang.String name;
   6:     private java.io.File logfile;
   7:     private java.io.OutputStream logstream;
   8:         ...
   9: public long getLastModified() {
  10:     return logfile.lastModified();
  11: }
  12:         ...
  13: public void open() throws IOException {
  14:     logfile = new File(name);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     private java.lang.String name;
   6:     private java.io.File logfile;
   7:     private java.io.OutputStream logstream;
   8:         ...
   9: public long getLastModified() {
  10:     return logfile.lastModified();
  11: }
  12:         ...
  13: public void open() throws IOException {
  14:     logfile = new File(name);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: 
   4:         ...
   5:         try {
   6:             File file = resource.getFile();
   7:         ...
   8:             return file.lastModified();
   9:         } catch (IOException ex) {

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: public class FileResource implements Resource {
   6:   private File _file;
   7: 
   8:         ...
   9:   public FileResource(File f) {
  10:     _file = f;
  11:         ...
  12:   public long lastModified() {
  13:     return _file.lastModified();

View Full Code Here

length

public long length()
Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the file
Usages and Demos :

View More Examples of length()
   1: package fr.jayasoft.ivy.repository.file;
   2: 
   3:         ...
   4: import java.io.File;
   5: 
   6:         ...
   7: public class FileResource implements Resource {
   8:     private File _file;
   9: 
  10:         ...
  11:     public long getContentLength() {
  12:         return _file.length();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     private java.lang.String name;
   6:     private java.io.File logfile;
   7:     private java.io.OutputStream logstream;
   8:         ...
   9: public long getSize() {
  10:     return logfile.length();
  11: }
  12:         ...
  13: public void open() throws IOException {
  14:     logfile = new File(name);

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     private final File file;
   7:     private final String hashString;
   8:         ...
   9:             h = Integer.toHexString(hash[i] & 0xff);
  10:             if(h.length() == 1) h = "0" + h;
  11:             sb.append(h);
  12:         ...
  13:     public long getFileSize() {
  14:         return file.length();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     private java.lang.String name;
   6:     private java.io.File logfile;
   7:     private java.io.OutputStream logstream;
   8:         ...
   9: public long getSize() {
  10:     return logfile.length();
  11: }
  12:         ...
  13: public void open() throws IOException {
  14:     logfile = new File(name);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: public class FilePartDataSource implements PartDataSource {
   6:     private final File file;
   7: 
   8:         ...
   9:     public long getSize() {
  10:         return file.length();
  11:     }

View Full Code Here

list

public String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the directory
Usages and Demos :

View More Examples of list()
   1: 
   2: import java.io.File;
   3: import java.lang.reflect.Method;
   4:         ...
   5:     
   6:     public static boolean deleteDir(File dir) {
   7:         if (dir.isDirectory()) {
   8:         ...
   9:             String[] children = dir.list();
  10:             for (int i = 0; i < children.length; i++) {
  11:         ...
  12:                 boolean success = deleteDir(new File(dir, children[i]));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.InputStream;
   4:         ...
   5: public class FileFileIO extends sun.io.FileIO {
   6:     File file;
   7:     protected FileFileIO(String path) {
   8:         ...
   9:     public String[] list() {
  10:         return file.list();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:     public List getChildren(Object element) {
   6:         File folder = (File) element;
   7:         ...
   8:         String[] children = folder.list();
   9:         int childrenLength = children == null ? 0 : children.length;

View Full Code Here
   1:         
   2:         File dir = new File(directoryName);
   3:         
   4:         ...
   5:         String[] children = dir.list();
   6:         if (children == null) 
   7:         ...
   8:                 
   9:                     outList = runExecutable("jar xvf " + directoryName + File.separatorChar + filename); 
  10:                 }
  11:         ...
  12:         {
  13:             String[] children = dir.list();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: {
   6:     public static boolean deleteFilesInDir(File dir)
   7:     {
   8:         ...
   9:         {
  10:             String[] children = dir.list();
  11:             for (int i = 0; i < children.length; i++)
  12:         ...
  13:             {
  14:                 boolean success = deleteDir(new File(dir, children[i]));

View Full Code Here

list

public String[] list(FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the list() method, except that the strings in the returned array must satisfy the filter. If the given filter is null then all names are accepted. Otherwise, a name satisfies the filter if and only if the value true results when the FilenameFilter.accept(File,String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
Parameters:
filter - A filename filter
Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname that were accepted by the given filter. The array will be empty if the directory is empty or if no names were accepted by the filter. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the directory
Usages and Demos :

View More Examples of list(FilenameFilter filter)
   1: 
   2: import java.io.File;
   3: import java.io.FilenameFilter;
   4:         ...
   5:     public void start() {
   6:         File rootDir = new File(".");
   7:         FilenameFilter fileFilter = new SuffixFileFilter(".xml");
   8:         ...
   9:         String[] xmlFiles = rootDir.list( fileFilter );
  10:         System.out.println( "*** XML Files" );
  11:         ...
  12: 
  13:         String[] htmlFiles = rootDir.list(fileFilter);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FilenameFilter;
   4:         ...
   5: {
   6:    private File   _file;
   7:    private String _dirName;
   8:         ...
   9:       _dirName = dir_name;
  10:       if( _dirName.endsWith(File.separator) == false )
  11:          _dirName = _dirName.concat(File.separator);
  12:         ...
  13:    {
  14:       String[] list = _file.list(this);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private final File baseDirectory;
   7: 
   8:         ...
   9:     public FileStreamStrategy(File baseDirectory) {
  10:         this(baseDirectory, new XStream());
  11:         ...
  12:     public int size() {
  13:         return baseDirectory.list(filter).length;

View Full Code Here
   1:     private WritableData dataObj;
   2:     private static final String BIN_FOLDER = File.separator + "bin";
   3:         ...
   4:     private static final String LIB_FOLDER = File.separator + "lib";
   5:     private static final String JAR_EXT = ".jar";
   6:         ...
   7:         
   8:         File fileObj = new File(sourceName);
   9:         ...
  10:         String[] fileNames = fileObj.list(filter);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:     private static class BaseFileReference extends FileReference {
   6:         private File file;
   7: 
   8:         ...
   9:         public String[] list(FilenameFilter filter) {
  10:             return file.list(filter);
  11:         }

View Full Code Here

listFiles

public File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(java.io.File, java.lang.String) File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the directory
Since:
1.2
Usages and Demos :

View More Examples of listFiles()
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class DirectoryFileLister implements FileLister {
   6:     private File directory;
   7: 
   8:         ...
   9:     public DirectoryFileLister(File directory) {
  10:         this.directory = directory;
  11:         ...
  12:     public File[] listFiles() {
  13:         return directory.listFiles();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.util.Date;
   4:         ...
   5:             public Object[] getElements(Object inputElement) {
   6:                 File dir = (File)inputElement;
   7:         ...
   8:                 return dir.listFiles();
   9:             }

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:     protected AMUserHomeDir homeDir;
   6:     protected File rootDirectory;
   7: 
   8:         ...
   9:     public AMUserUploadDirectoryImpl(AMUserHomeDir aHomeDir, File aRootDir) {
  10:         super();
  11:         ...
  12:     public File[] listFiles() {
  13:         return rootDirectory.listFiles();

View Full Code Here
   1: import org.exoplatform.services.jcr.storage.Container;
   2: import java.io.File;
   3: import java.util.ArrayList;
   4:         ...
   5: 
   6:   FolderNodeContainer(String jcrPath, File storage) {
   7:     super(jcrPath, "nt:folder", storage);
   8:         ...
   9: 
  10:     File[] cFiles = storage.listFiles();
  11:     for (int i = 0; i < cFiles.length; i++){
  12:         ...
  13: 
  14:   final void deleteRecursively(File file) {

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:             aLocation = new File("stores/").toURL();
   7:             if (aLocation != null)
   8:         ...
   9:         {
  10:             String aStr = theURL.toExternalForm().substring(theURL.toExternalForm().indexOf("file:/")+6);
  11:             aStr = aStr.replaceAll("%20"," ").replace('/','\\');
  12:         ...
  13:             {
  14:                 File[] aDirList = aStoreDir.listFiles();

View Full Code Here

listFiles

public File[] listFiles(FileFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FileFilter.accept(File) method of the filter is invoked on the pathname.
Parameters:
filter - A file filter
Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the directory
Since:
1.2
Usages and Demos :

View More Examples of listFiles(FileFilter filter)
   1:   {
   2:     File myDir = new File("I:/jdk1.2/src/java/io");
   3:     System.out.println(myDir.getAbsolutePath()
   4:         ...
   5: 
   6:     File[] contents = myDir.listFiles(select);
   7: 
   8:         ...
   9:         System.out.println(contents[i] + " is a " +
  10:                 (contents[i].isDirectory() ? "directory":"file") +
  11:                 " last modified " + new Date(contents[i].lastModified()));

View Full Code Here
   1: import java.io.File;
   2: import java.io.FilenameFilter;
   3:         ...
   4: 
   5:     File myDir = new File("C:/j2sdk1.4.0/src/java/io");
   6:     System.out.println(myDir.getAbsolutePath() 
   7:         ...
   8: 
   9:     File[] contents = myDir.listFiles(select);

View Full Code Here
   1: 
   2: import de.jose.util.file.FileUtil;
   3: 
   4:         ...
   5: import java.io.File;
   6: import java.io.FileFilter;
   7:         ...
   8: {
   9:     public static String[] list(File dir, boolean acceptStream)
  10:     {
  11:         ...
  12:         else
  13:             return dir.listFiles((FileFilter)new Jo3DFilter(acceptStream));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileFilter;
   4:         ...
   5:     {
   6:         final File file = new File(rootDir);
   7:         final List removedDirs = new ArrayList();
   8:         ...
   9:     {
  10:         final File[] cvsDirs = file.listFiles(cvsDirFilter);
  11:         for (int i = 0; i < cvsDirs.length; i++)
  12:         ...
  13: 
  14:         final File[] subdirs = file.listFiles(dirFilter);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.util.Arrays;
   4:         ...
   5:         try {
   6:             File[] f = getFiles();
   7:             int num = getNumberOfBackups(f);
   8:         ...
   9:     
  10:     public File getLatestFile() throws BackupException {
  11:         File[] f = getFiles();
  12:         ...
  13:         FilenameFilter filter = getFileNameFilter();
  14:         return f.listFiles(filter);

View Full Code Here

listFiles

public File[] listFiles(FilenameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FilenameFilter.accept(File,String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
Parameters:
filter - A filename filter
Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method denies read access to the directory
Since:
1.2
Usages and Demos :

View More Examples of listFiles(FilenameFilter filter)
   1:   {
   2:     File myDir = new File("I:/jdk1.2/src/java/io");
   3:     System.out.println(myDir.getAbsolutePath()
   4:         ...
   5: 
   6:     File[] contents = myDir.listFiles(select);
   7: 
   8:         ...
   9:         System.out.println(contents[i] + " is a " +
  10:                 (contents[i].isDirectory() ? "directory":"file") +
  11:                 " last modified " + new Date(contents[i].lastModified()));

View Full Code Here
   1: import java.io.File;
   2: import java.io.FilenameFilter;
   3:         ...
   4: 
   5:     File myDir = new File("C:/j2sdk1.4.0/src/java/io");
   6:     System.out.println(myDir.getAbsolutePath() 
   7:         ...
   8: 
   9:     File[] contents = myDir.listFiles(select);

View Full Code Here
   1: 
   2: import de.jose.util.file.FileUtil;
   3: 
   4:         ...
   5: import java.io.File;
   6: import java.io.FileFilter;
   7:         ...
   8: {
   9:     public static String[] list(File dir, boolean acceptStream)
  10:     {
  11:         ...
  12:         else
  13:             return dir.listFiles((FileFilter)new Jo3DFilter(acceptStream));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileFilter;
   4:         ...
   5:     {
   6:         final File file = new File(rootDir);
   7:         final List removedDirs = new ArrayList();
   8:         ...
   9:     {
  10:         final File[] cvsDirs = file.listFiles(cvsDirFilter);
  11:         for (int i = 0; i < cvsDirs.length; i++)
  12:         ...
  13: 
  14:         final File[] subdirs = file.listFiles(dirFilter);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.File;
   3: import java.util.Arrays;
   4:         ...
   5:         try {
   6:             File[] f = getFiles();
   7:             int num = getNumberOfBackups(f);
   8:         ...
   9:     
  10:     public File getLatestFile() throws BackupException {
  11:         File[] f = getFiles();
  12:         ...
  13:         FilenameFilter filter = getFileNameFilter();
  14:         return f.listFiles(filter);

View Full Code Here

listRoots

public static File[] listRoots()
List the available filesystem roots.

A particular Java platform may support zero or more hierarchically-organized file systems. Each file system has a root directory from which all other files in that file system can be reached. Windows platforms, for example, have a root directory for each active drive; UNIX platforms have a single root directory, namely "/". The set of available filesystem roots is affected by various system-level operations such as the insertion or ejection of removable media and the disconnecting or unmounting of physical or virtual disk drives.

This method returns an array of File objects that denote the root directories of the available filesystem roots. It is guaranteed that the canonical pathname of any file physically present on the local machine will begin with one of the roots returned by this method.

The canonical pathname of a file that resides on some other machine and is accessed via a remote-filesystem protocol such as SMB or NFS may or may not begin with one of the roots returned by this method. If the pathname of a remote file is syntactically indistinguishable from the pathname of a local file then it will begin with one of the roots returned by this method. Thus, for example, File objects denoting the root directories of the mapped network drives of a Windows platform will be returned by this method, while File objects containing UNC pathnames will not be returned by this method.

Unlike most methods in this class, this method does not throw security exceptions. If a security manager exists and its SecurityManager.checkRead(String) method denies read access to a particular root directory, then that directory will not appear in the result.

Returns:
An array of File objects denoting the available filesystem roots, or null if the set of roots could not be determined. The array will be empty if there are no filesystem roots.
Since:
1.2
Usages and Demos :

View More Examples of listRoots()
   1:    {
   2:       File [] roots = File.listRoots();
   3:       for (int i = 0; i < roots.length; i++)
   4:       {
   5:            System.out.println ("Partition: "+roots [i]);

View Full Code Here
   1: import javax.swing.BorderFactory;
   2: import static java.io.File.listRoots;
   3: 
   4:         ...
   5: import static javax.swing.WindowConstants.*;
   6: import static java.io.File.createTempFile;
   7: import static sun.net.ftpclient.FtpClient.*;
   8:         ...
   9: {
  10:     private Class mUse2 = java.io.File.class;
  11:     private Class mUse4 = java.util.Enumeration[].class;

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.awt.image.BufferedImage;
   4:         ...
   5:     {
   6:         File[] drives = File.listRoots();
   7:         for (int i = 0; i < drives.length; i++)
   8:         ...
   9:         {
  10:             File drive = drives[i];
  11:             System.out.println("Analyzing drive " + drive + "...");

View Full Code Here
   1: 
   2: import java.io.File;
   3: import edu.cmu.sun.ListItemModel;
   4:         ...
   5: 
   6:     public File[] getRoots() {
   7:         
   8:         ...
   9:         File[] files = File.listRoots();
  10:         
  11:         ...
  12:     public String getFilesystemSeparator() {
  13:         return java.io.File.separator;

View Full Code Here
   1:     if (home != null) {
   2:         File fhome = new File(home);
   3:         if (fhome.isDirectory()) {
   4:         ...
   5:     }
   6:     File[] roots = File.listRoots();
   7:     for (int i = 0 ; i < roots.length ; i++) { 
   8:         root.add(new LocalNode(roots[i], roots[i].getAbsolutePath())); 
   9:     }

View Full Code Here

mkdir

public boolean mkdir()
Creates the directory named by this abstract pathname.
Returns:
true if and only if the directory was created; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method does not permit the named directory to be created
Usages and Demos :

View More Examples of mkdir()
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     {
   6:         File logDir = new File("logs");
   7:         if(!logDir.exists())
   8:         ...
   9:             logDir.mkdir();
  10:     }

View Full Code Here
   1: 
   2:       File aFile = new File(dir, "data.txt"); 
   3: 
   4:       DataOutputStream myStream = new DataOutputStream(
   5:                                     new FileOutputStream(aFile));

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:     public static void main(String[] args) {
   6:         File base = new File(SimpleFileStore.ff);
   7:         if (!base.exists())
   8:         ...
   9:             base.mkdir();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:   static {
   6:     File directory = new File("/Users/sandbox/pebble/blogs", "test");
   7:     log.debug("Creating " + directory.getAbsolutePath());
   8:         ...
   9:     directory.mkdir();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:         LockManager lockManager = new LockManager();
   6:         File root = new File(System.getProperty("java.io.tmpdir"),
   7:                 "GFileManager");
   8:         ...
   9:         Util.recursiveDelete(root);
  10:         root.mkdir();
  11:         

View Full Code Here

mkdirs

public boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
Returns:
true if and only if the directory was created, along with all necessary parent directories; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(String) method does not permit verification of the existence of the named directory and all necessary parent directories; or if the SecurityManager.checkWrite(String) method does not permit the named directory and all necessary parent directories to be created
Usages and Demos :

View More Examples of mkdirs()
   1: 
   2: import java.io.File;
   3: import java.io.FileWriter;
   4:         ...
   5: public class FileLogger implements Logger {
   6:     protected File dest;
   7: 
   8:         ...
   9:     public FileLogger(String filename) {
  10:         dest = new File(filename);
  11:         ...
  12:         dest.mkdirs();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class JUnitConverterTest {
   6:   private File m_output;
   7: 
   8:         ...
   9:   public void convert(String inputDir) {
  10:     File inputDirFile= new File(inputDir);
  11:     m_output= new File(inputDir, "generated");
  12:         ...
  13:     m_output.mkdirs();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     protected File m_systemDir;
   7: 
   8:         ...
   9:     public LocalProfile(String profileID, Corpus corpus, CacheFactory cacheFactory, File systemDir) {
  10:         super(profileID, corpus, cacheFactory);
  11:         ...
  12:         if (!m_systemDir.exists()) {
  13:             m_systemDir.mkdirs();

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:     protected final File rootDir;
   7: 
   8:         ...
   9:     public AMPublishDirectoryImpl(IAMApplication app, File aDirectory) {
  10:         application = app;
  11:         ...
  12:         rootDir = aDirectory;
  13:         rootDir.mkdirs();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.text.CharacterIterator;
   4:         ...
   5: public class FileUtils {
   6:     public static File ensureDirectory(File dir) {
   7:         if (!dir.exists()) {
   8:         ...
   9:             dir.mkdirs();
  10:         }

View Full Code Here

renameTo

public boolean renameTo(File dest)
Renames the file denoted by this abstract pathname.

Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.

Parameters:
dest - The new abstract pathname for the named file
Returns:
true if and only if the renaming succeeded; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method denies write access to either the old or new pathnames
NullPointerException - If parameter dest is null
Usages and Demos :

View More Examples of renameTo(File dest)
   1: 
   2: import java.io.File;
   3: import java.util.ArrayList;
   4:         ...
   5: 
   6:     public static void backupFile(File f) {
   7:         ...
   8:     File bf = new File(getBase(f.getPath()) + ".bak");
   9:     if (bf.exists()) {
  10:         ...
  11:     }
  12:     f.renameTo(bf);

View Full Code Here
   1: import java.io.BufferedReader;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:     private final File _file0;
   7: 
   8:         ...
   9:     private final File _file1;
  10: 
  11:         ...
  12:                 _file1.delete();
  13:                 _file0.renameTo(_file1);

View Full Code Here
   1: 
   2:     private static final String FILE = "File";
   3: 
   4:         ...
   5: 
   6:     String[] names = multipart.getFileNameValues(FILE);
   7:         ...
   8:     String[] temps = multipart.getLocalPathValues(FILE);
   9:     String[] types = multipart.getFileTypeValues(FILE);
  10:         ...
  11:     File dst = new File("/var/tmp/", filename);
  12:     src.renameTo(dst);

View Full Code Here
   1:   String getBackupThemeDirectory() {
   2:     return blog.getRoot() + File.separator + "theme";
   3:   }
   4:         ...
   5: 
   6:   public File getPathToLiveTheme() {
   7:         ...
   8:     return new File(pathToLiveThemes, name);
   9:   }
  10:         ...
  11:     if (blogTheme.exists()) {
  12:       blogTheme.renameTo(blogThemeBackup);

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5:   public static final String normalisePathName(String pathName) {
   6:     pathName = pathName.replace(java.io.File.separatorChar, '/');
   7:     if (pathName.length() >= 2 && pathName.charAt(1) == ':') {
   8:         ...
   9:     }
  10:     pathName = pathName.replace('/', java.io.File.separatorChar);
  11:     return pathName;
  12:         ...
  13:     bakFile.delete();
  14:     file.renameTo(bakFile);

View Full Code Here

setLastModified

public boolean setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname.

All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified() method will return the (possibly truncated) time argument that was passed to this method.

Parameters:
time - The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
Returns:
true if and only if the operation succeeded; false otherwise
Throws:
IllegalArgumentException - If the argument is negative
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method denies write access to the named file
Since:
1.2
Usages and Demos :

View More Examples of setLastModified(long time)
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     public void touch() throws RemoteException, SmartFrogException {
   6:         String file = getFile().getAbsolutePath();
   7:         try {
   8:         ...
   9:             touch(file, age);
  10:         } catch (IOException e) {
  11:         ...
  12:         if (age >= 0) {
  13:             file.setLastModified(age);

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: 
   6:   private File semaphoreFile = null;
   7:   private boolean semaphoreAquired = false;
   8:         ...
   9:   public FileSemaphore(String fileToGuard, long timeoutAfterMillis, boolean isReadOnly) {
  10:     semaphoreFile = new File(fileToGuard + ".sem");
  11:     this.semaphoreTimeoutMillis = timeoutAfterMillis;
  12:         ...
  13:           if (System.currentTimeMillis()-semaphoreTimeoutMillis > lastModified) {
  14:             semaphoreFile.setLastModified(System.currentTimeMillis());

View Full Code Here
   1: 
   2: import org.opencms.file.CmsResource;
   3: import org.opencms.util.CmsFileUtil;
   4:         ...
   5: 
   6: import java.io.File;
   7: import java.io.IOException;
   8:         ...
   9: 
  10:         m_rfsRepository = CmsFileUtil.normalizePath(basepath + foldername + File.separatorChar);
  11:     }
  12:         ...
  13:                 if ((System.currentTimeMillis() - age) > 3600000) {
  14:                     f.setLastModified(System.currentTimeMillis());

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:         m_rfsRepository = CmsFileUtil.normalizePath(basepath + foldername + File.separatorChar);
   7:     }
   8:         ...
   9: 
  10:     protected static File saveFile(String rfsName, byte[] content) throws IOException {
  11: 
  12:         ...
  13:         File f = saveFile(rfsName, content);
  14:         f.setLastModified(dateLastModified);

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private File file;
   7: 
   8:         ...
   9:     {
  10:         file.setLastModified(modtime);
  11:     }

View Full Code Here

setReadOnly

public boolean setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory is guaranteed not to change until it is either deleted or marked to allow write access. Whether or not a read-only file or directory may be deleted depends upon the underlying system.
Returns:
true if and only if the operation succeeded; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkWrite(String) method denies write access to the named file
Since:
1.2
Usages and Demos :

View More Examples of setReadOnly()
   1:          String no_write_dir = "no_write_dir";
   2:          File noWriteDirFd = new File( no_write_dir );
   3:          if ( ! noWriteDirFd.exists() )
   4:         ...
   5:          }
   6:          noWriteDirFd.setReadOnly();
   7:          String no_read_file = "no_read_file.java";
   8:         ...
   9:          File noReadFileFd = new File( no_read_file );
  10:          noReadFileFd.createNewFile();
  11:         ...
  12:          noReadFileFd.setReadOnly();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:   protected File f;
   7:   private static final Random rnd = new Random(System.currentTimeMillis());
   8:         ...
   9:               Log.ASSERTFAILED);
  10:     init(new File(parent != null ? ((AbstractSyxawFile) parent).f : null, child));
  11:   }
  12:         ...
  13:     if (smd.getReadOnly())
  14:       f.setReadOnly();

View Full Code Here

toString

public String toString()
Returns the pathname string of this abstract pathname. This is just the string returned by the getPath() method.
Overrides:
toString in interface Object
Returns:
The string form of this abstract pathname
Usages and Demos :

View More Examples of toString()
   1: import java.io.BufferedOutputStream;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     public void actionPerformed(ActionEvent evt) {
   6:         File f = null;
   7:         scaler.setImage(display.getOffscreenBuffer());
   8:         ...
   9:         if ( !format.equals(ext) ) {
  10:             f = new File(f.toString()+"."+format);
  11:         }

View Full Code Here
   1: import java.io.BufferedOutputStream;
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:         
   6:         File f = null;
   7:         scaler.setImage(display.getOffscreenBuffer());
   8:         ...
   9:         if ( !format.equals(ext) ) {
  10:             f = new File(f.toString()+"."+format);
  11:         }

View Full Code Here
   1: 
   2: import java.io.File;
   3: public class PnkFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter {
   4:         ...
   5: }
   6: public boolean accept(File pathname) {
   7:     if (pathname.isDirectory()) {
   8:         ...
   9:         while (i != -1) {
  10:             if (pathname.toString().endsWith("." + e.substring(0, i)) || e.substring(0, i).equals("*")) {
  11:                 if ((pathname.canRead()) || (! pathname.exists())) {
  12:         ...
  13:                 else {
  14:                     System.out.println("can't read file " + pathname.toString());

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class StyleConfig {
   6:     private File filename = null;
   7: 
   8:         ...
   9:         id = style.getId();
  10:         filename = new File(style.getFilename().toString());
  11:         _default = style.isDefault();        
  12:         ...
  13:         id = style.getId();
  14:         filename = new File(style.getFilename().toString());

View Full Code Here
   1: 
   2:     public void writeObject(File file, Storable object)
   3:         throws StorageException
   4:         ...
   5:         try {
   6:             fos = new FileOutputStream(file);
   7:         } catch(FileNotFoundException e) {
   8:         ...
   9:         } catch (JDOMException e) {
  10:             System.out.println("SAXBuilder threw error for file '" + file.toString() + "'.");
  11:             throw new StorageException(e);

View Full Code Here

toURI

public URI toURI()
Constructs a file: URI that represents this abstract pathname.

The exact form of the URI is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash.

For a given abstract pathname f, it is guaranteed that

new File( f.toURI()).equals( f.getAbsoluteFile())
so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. Due to the system-dependent nature of abstract pathnames, however, this relationship typically does not hold when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
Returns:
An absolute, hierarchical URI with a scheme equal to "file", a path representing this abstract pathname, and undefined authority, query, and fragment components
Since:
1.4
Usages and Demos :

View More Examples of toURI()
   1: 
   2: import java.io.File;
   3: import java.io.InputStream;
   4:         ...
   5:     
   6:     private final File file;
   7:     
   8:         ...
   9:             try {
  10:                 return file.toURI().toURL();
  11:             } catch (MalformedURLException e) {

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private File file;
   7: 
   8:         ...
   9:     public URI getURI() {
  10:         return file.toURI();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     File directory;
   7:     
   8:         ...
   9:     public PropertyService(Catalog parent, Map params, File directory) {
  10:         super(parent, params);
  11:         ...
  12:     public URI getIdentifier() {
  13:         return directory.toURI();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     File file;
   7:     
   8:         ...
   9:     public URI getIdentifier() {
  10:         return file.toURI();
  11:     }

View Full Code Here
   1:       if (akentiHome != null) {
   2:         File schemaFile = new File(akentiHome + "/xml/schema/AkentiCertificate.xsd");
   3:         if (schemaFile.exists()) {
   4:         ...
   5:                               schemaFile.toURI().toString());
   6:         }
   7:       }     
   8:       parser.parse(new InputSource(new InputStreamReader(is)));

View Full Code Here

toURL

public URL toURL()
            throws MalformedURLException
Converts this abstract pathname into a file: URL. The exact form of the URL is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URL will end with a slash.

Usage note: This method does not automatically escape characters that are illegal in URLs. It is recommended that new code convert an abstract pathname into a URL by first converting it into a URI, via the toURI method, and then converting the URI into a URL via the URI.toURL method.

Returns:
A URL object representing the equivalent file URL
Throws:
MalformedURLException - If the path cannot be parsed as a URL
Since:
1.2
Usages and Demos :

View More Examples of toURL()
   1: 
   2: import java.io.File;
   3: import java.net.MalformedURLException;
   4:         ...
   5: 
   6: import fr.jayasoft.ivy.repository.file.FileResource;
   7: import fr.jayasoft.ivy.repository.url.URLResource;
   8:         ...
   9: public class ResourceHelper {
  10:     public static boolean equals(Resource res, File f) {
  11:         if (res == null && f == null) {
  12:         ...
  13:             try {
  14:                 return f.toURL().toExternalForm().equals(res.getName());

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     static final File TEST_FILE = new File("conf/test.xml");
   7: 
   8:         ...
   9:     {
  10:         return TEST_FILE.toURL();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: public class FileResource implements Resource {
   6:   private File _file;
   7: 
   8:         ...
   9:   public FileResource(File f) {
  10:     _file = f;
  11:         ...
  12:     try {
  13:       return _file.toURL().toExternalForm();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:   protected InputStream getResourceAsStream(String name) throws Exception {
   6:     File file = new File(groovyPath_ +  "/" + name) ;
   7:     if(file.exists()) return  new FileInputStream(file);
   8:         ...
   9:     File file = new File(groovyPath_ +  "/" + name) ;
  10:     if(file.exists()) return  file.toURL() ;
  11:     ClassLoader cl = Thread.currentThread().getContextClassLoader() ;

View Full Code Here
   1: public class FileBundleEntry extends BundleEntry {
   2:     private File file;
   3:     String name;
   4:         ...
   5: 
   6:     FileBundleEntry(File file, String name) {
   7:         this.file = file;
   8:         ...
   9:         try {
  10:             return file.toURL();
  11:         } catch (MalformedURLException e) {

View Full Code Here