13.07.2015 Views

I/O Fundamentals

I/O Fundamentals

I/O Fundamentals

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java Input and Outputboolean setReadOnly()(since 1.2)voidsetLastModified(long)(since 1.2)Marks the file read-only (returns true if succeeded)Explicitly sets the modification time of a fileFile Name MethodsThe following table shows the methods of the File class that relate to getting thefile name, or part of it.Some of the examples in this table use the following declaration:File a = new File("\\windows\system\smurf.gif");int compareTo(File)int compareTo(Object)(both since 1.2)booleanequals(Object)FilegetAbsoluteFile()(since 1.2)StringgetAbsolutePath()StringgetCanonicalPath()Compares the file name to another file name orobject, returning an int that represents the sortingorderCompares the file names to see if they are equivalentGets an abstract file name that represents resolutionof the absolute file name for this FileResolves the absolute file name for this FileGets an abstract file name that is unique for thecurrent File. Note that the actual name isdependent on the file system and is always anabsolute file name. On Windows, for example, thecanonical path is the absolute file name including thereal case of the file and path names.a.getCanonicalPath() ==>"c:\WINDOWS\SYSTEM\smurf.gif"FilegetCanonicalFile()(since 1.2)String getName()Same as new File(getCanonicalPath())Returns the name for the file without any precedingpath information.Java Input and Output -4© 1996-2003 jGuru.com. All Rights Reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!