Create directories in JSP
Abstract: to create directories in JSP
</ Td> </ tr> <tr> <td width="540" height="35" valign="top" class="ArticleTeitle"> <% –
Author: Hua Lian [hlian@alleasy.net]
Date: 2000-07-20-10-10
Version: 1.0
Features: JSP routines - to create directories in JSP
Call:
Paper trails path
Mkdir (String path)
Back to:
Air operations for the successful return
Operation failed to return to the reasons for failure.
If there is the question to invite feedback to hlian@alleasy.net.
–%>
<% @ Page contentType = "text / html; gb2312 charset ="%>
<% @ Page import = "java.io. *"%>
<%!
String Mkdir (String path) (
String msg = null;
Java.io.File dir;
/ / Object new document
Dir = new java.io.File (path);
If (dir == null) (
Msg = "wrong reasons:
Sorry, can not create space directory! ";
Return msg;
)
If (dir.isFile ()) (
Msg = "wrong reasons:
Have the same name document "+ dir.getAbsolutePath () +" there. ";
Return msg;
)
If (! Dir.exists ()) (
Boolean result = dir.mkdirs ();
If (result == false) (
Msg = "wrong reasons:
Contents "+ dir.getAbsolutePath () +" failure to create, for unknown reasons! ";
Return msg;
)
/ / Create directories, if successful, no output.
Msg = "successfully created directory:" + dir.getAbsolutePath () + "";
Return msg;
Else ()
Msg = "wrong reasons:
Contents "+ dir.getAbsolutePath () +" already exists. ";
)
Return msg;
)
%>
<%
String filepath = "usr / home / hoyi / html / dir";
String opmsg = Mkdir (filepath);
Out.println (opmsg);
%>
</ Td> <td width="173" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
↑ Back
Tags: JSP






