Differences between mkdir and mkdirs

Source: Internet
Author: User

I encountered a situation that was deployed to WebLogic and tomcat,

However, WebLogic cannot get the servletcontext,

Therefore, use the following method to obtain the data:

Thread. currentthread (). getcontextclassloader (). getresource (""). getpath ();

In this way, the paths obtained under the two servers are:

Tomcat get path:/WEB-INF/classes/

WebLogic: The corresponding domain root directory ..

When you use mkdir () to create a folder in the obtained path, Weblogic is created successfully and Tomcat is not created successfully!
Use mkdirs (), and both servers are created successfully.

The following is an explanation on the Internet,

Bytes -------------------------------------------------------------------------------------------------------

Boolean mkdir ()
Create the directory specified by this abstract path.
Boolean mkdirs ()
Create the directory specified by this abstract path name, including the parent directory that is required but does not exist.
PS: from Doc. It is recommended that you check the API.

Bytes -------------------------------------------------------------------------------------------------------

Bytes -------------------------------------------------------------------------------------------------------

The document is like tianshu! Let me explain the actual points:

Mkdir (): Only one directory can be created.
For example, file = new file ("C:/AA ");
File. mkdir (); // you can create an AA directory under C :/.
If there are multiple levels of directories, mkdir cannot be used to create: file = new file ("C:/AA/BB"); file. mkdir () // cannot be created.
It should be changed:
Mkdirs ():

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.