Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulate virtual directories or web applications from a java program

Status
Not open for further replies.

sohaib

Programmer
Jul 21, 2001
2
0
0
PK

How to manipulate - add, delete, update or explore - virtual directories and/or web applications from a java application or servlet?
 
There are a quite of Java Classes for purposes such as these. Try asking a particular question like, "How do I create a file?". As an example the following creates a new file and then deletes it:
Code:
String filename = "C:\newfile.txt";
File f = new File(filename);
try {
  /* Create File */
  if (f.createNewFile()) {
    System.out.println("File sucessfully created");
  }
  else {
    System.out.println("File already exists");
  }
  /* Delete File */
  if (f.delete()) {
    System.out.println("File sucessfully deleted");
  }
  else {
    System.out.println("File not deleted");
  }
}
catch (IOException ioe) {
  ioe.printStackTrace();
}
Wushutwist
 
thank for your response but this question i wanted to ask is not about files and directories of a file system but virtual directories of a web server.
 
You can translate a virtual path into a "real" path using
Code:
String ServletContext.getRealPath(String path)
. Things such as creating and deleting files cannot take place on virtual paths without the "real" translation being done first. Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top