![]() |
||
![]() |
![]() Alden Hosting provides professional, efficient, and reliable business-class Web hosting services to small- and medium-sized businesses. |
|
|
JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER, |
||||||||||||||||||||||||||||||||||||||||||
| Method Invoked | Returns on Microsoft Windows | Returns on Solaris |
|---|---|---|
a.toString() |
xanadu.txt |
xanadu.txt |
a.getName() |
xanadu.txt |
xanadu.txt |
b.getParent() |
NULL |
NULL |
a.getAbsolutePath() |
c:\java\examples\xanadu.txt |
/home/cafe/java/examples/xanadu.txt |
a.getCanonicalPath() |
c:\java\examples\xanadu.txt |
/home/cafe/java/examples/xanadu.txt |
Then the same program constructs a File object from a
more complicated file name, using
File.separator
to specify the file name in a platform-independent way.
File b = new File(".." + File.separator + "examples" + File.separator + "xanadu.txt");
Although b refers to the same file as a, the
methods return slightly different values:
| Method Invoked | Returns on Microsoft Windows | Returns on Solaris |
|---|---|---|
b.toString() |
..\examples\xanadu.txt |
../examples/xanadu.txt |
b.getName() |
xanadu.txt |
xanadu.txt |
b.getParent() |
..\examples |
../examples |
b.getAbsolutePath() |
c:\java\examples\..\examples\xanadu.txt |
/home/cafe/java/examples/../examples/xanadu.txt |
b.getCanonicalPath() |
c:\java\examples\xanadu.txt |
/home/cafe/java/examples/xanadu.txt |
Running the same program on a Linux system would give results similar to those on the Solaris system.
It's worth mentioning that
File.compareTo()would not consider a and b to be the same.
Even though they refer to the same file, the names used to construct
them are different.
The
FileStuff
example creates File objects from names passed from the
command line and exercises various information methods on them. You'll
find it instructive to run FileStuff on a variety of file
names. Be sure to include directory names as well as the names of
files that don't actually exist. Try passing FileStuff a
variety of relative and absolute path names.
File object names an actual file, a program can use
it to perform a number of useful operations on the file. These
include passing the object to the constructor for a stream to open the
file for reading or writing.
The delete method deletes the file immediately,
while the deleteOnExit method deletes the file when
the virtual machine terminates.
The setLastModified sets the modification date/time for
the file. For example, to set the modification time of
xanadu.txt to the current time, a program could do
new File("xanadu.txt").setLastModified(new Date().getTime());
The renameTo() method renames the file. Note that the
file name string behind the File object remains
unchanged, so the File object will not refer to the
renamed file.
File has some useful methods for working with
directories.
The mkdir method creates a directory. The
mkdirs method does the same thing, after first creating
any parent directories that don't yet exist.
The list and listFiles methods list the
contents of a directory. The list method returns an array
of String file names, while listFiles
returns an array of File objects.
File contains some useful static methods.
The createTempFile method creates a new file with a
unique name and returns a File object referring to it
The listRoots returns a list of file system root names.
On Microsoft Windows, this will be the root directories of mounted
drives, such as a:\ and c:\. On UNIX and
Linux systems, this will be the root directory, /.
Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans WEB 4 PLAN and WEB 5 PLAN , WEB 6 PLAN .
At Alden Hosting we eat and breathe Java! We are the industry leader in providing affordable, quality and efficient Java web hosting in the shared hosting marketplace. All our sites run on our Java hosing platform configured for optimum performance using Java 1.6, Tomcat 6, MySQL 5, Apache 2.2 and web application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.
We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private Tomcat environment get their very own Tomcat server. You can start and re-start your entire Tomcat server yourself.
![]() |
|
http://alden-servlet-Hosting.com
JSP at alden-servlet-Hosting.com
Servlets at alden-servlet-Hosting.com
Servlet at alden-servlet-Hosting.com
Tomcat at alden-servlet-Hosting.com
MySQL at alden-servlet-Hosting.com
Java at alden-servlet-Hosting.com
sFTP at alden-servlet-Hosting.com
http://alden-tomcat-Hosting.com
JSP at alden-tomcat-Hosting.com
Servlets at alden-tomcat-Hosting.com
Servlet at alden-tomcat-Hosting.com
Tomcat at alden-tomcat-Hosting.com
MySQL at alden-tomcat-Hosting.com
Java at alden-tomcat-Hosting.com
sFTP at alden-tomcat-Hosting.com
http://alden-sftp-Hosting.com
JSP at alden-sftp-Hosting.com
Servlets at alden-sftp-Hosting.com
Servlet at alden-sftp-Hosting.com
Tomcat at alden-sftp-Hosting.com
MySQL at alden-sftp-Hosting.com
Java at alden-sftp-Hosting.com
sFTP at alden-sftp-Hosting.com
http://alden-jsp-Hosting.com
JSP at alden-jsp-Hosting.com
Servlets at alden-jsp-Hosting.com
Servlet at alden-jsp-Hosting.com
Tomcat at alden-jsp-Hosting.com
MySQL at alden-jsp-Hosting.com
Java at alden-jsp-Hosting.com
sFTP at alden-jsp-Hosting.com
http://alden-java-Hosting.com
JSp at alden-java-Hosting.com
Servlets at alden-java-Hosting.com
Servlet at alden-java-Hosting.com
Tomcat at alden-java-Hosting.com
MySQL at alden-java-Hosting.com
Java at alden-java-Hosting.com
sFTP at alden-java-Hosting.com
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP at JSP.aldenWEBhosting.com
Servlets at servlets.aldenWEBhosting.com
Tomcat at Tomcat.aldenWEBhosting.com
mysql at mysql.aldenWEBhosting.com
Java at Java.aldenWEBhosting.com
Web Hosts Portal
Web Links
Web Links
Web Hosting
JSP Solutions Web Links
JSP Solutions Web Hosting
Servlets Solutions Web Links
Servlets Solutions Web Hosting
Web Links
Web Links
.
.
.
.
.
.
.
.
.
.
jsp hosting
servlets hosting
web hosting
web sites designed
cheap web hosting
web site hosting
myspace web hosting