Code to create a folder in java

Hi friends
I want to know how to create a folder in java using files concept.
Can any one send me the code to create a folder in our system using files concept.
Thanks in advance.

[http://java.sun.com/docs/books/tutorial/essential/io/file.html]

Similar Messages

  • Unable to create a folder through java code on weblogic server 10GR3

    Hi,
    I have java code which creates a folder and writes an XML file in to it.
    File saveDirectory = new File(storePath);
    if(!saveDirectory.exists()){
    System.out.println("directory doesnt exists");
    boolean isDirectoryCreated = saveDirectory.mkdir();
    System.out.println("directory doesnt exist creating status :"+isDirectoryCreated);
    This code works fine on my local weblogic server.Whereas the one installed on Unix box is not.
    saveDirectory.mkdir() is unable to create a directory at the given path.
    I feel there is some permission problems.
    Please let me know what can be done.
    Thanks,

    I have my Linux/Unix Admin either add me to a group that can do this or create one that can and add me to it.
    If you command prompt can you manually do it now?
    Best Regards
    mseberg

  • How to create a Folder using java.

    Hi All,
    I have a doubt. I want to create a folder using java.
    Inputs are the destination where the folder should be created and the name of the folder. Plz help me in this regard.
    thanks and regards,
    Vincent .R.

    check out javadoc for java.io
    File reldir=new File("NewDir");//relatively where your program runs
    reldir.mkdir();
    File absdir=new File("C:/NewDir");//absolute path
    reldir.mkdir();
    File newdir=new File(absdir,"SubDir");//defines another dir under absdir
    newdir.mkdir();
    Gil

  • How to create a folder through java

    Hi All,
    Can any one give the solution of my prob.
    I want to create a folder in windows m/c through java programe .Is it possible.
    If yes then kindly suggest me how...?
    Thanks In advance
    Vikas

    String newFolderPath = "C:\\";
    String newFolderName = "MyFolder";
    String spoonFeeding = newFolderPath + newFolderName;
    File f = new File(spoonFeeding);
    f.mkDir();

  • How to create a folder with java application?

    Hi expert
    I would like to read some tutorial or manual to understand the logic behind the management of the folder and document from a java application in KM.
    Anyone could help me?
    thank you
    Andrea

    Dear Andrea,
    Please have a look to below documents might help.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30a2a087-190f-2d10-07a4-dad666b44c1f?QuickLink=index&overridelayout=true
    http://wiki.sdn.sap.com/wiki/display/Snippets/KMLibrary-ReusableComponentforWebDynpro+Java
    Best Regards,
    Arun Jaiswal

  • Do u know how to write a few line of codes to create folder?

    hi all, I just need a few line of codes to create a folder in my directory. Can someone just write a few lines of codes to create a folder?Thanks!
    This is my unzip codes and I need to put these few lines of codes in the "/* */" part. If I didn't create the folder (using codes)then it would not be unzipped.
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    public class Unzip {
      public static final void copyInputStream(InputStream in, OutputStream out)
      throws IOException
        byte[] buffer = new byte[1024];
        int len;
        while((len = in.read(buffer)) >= 0)
          out.write(buffer, 0, len);
        in.close();
        out.close();
      public static final void main(String[] args) {
        Enumeration entries;
        ZipFile zipFile;
        try {
          zipFile = new ZipFile("C:\\Temp\\FolderZiper.zip");
          entries = zipFile.entries();
          while(entries.hasMoreElements()) {
            ZipEntry entry = (ZipEntry)entries.nextElement();
    /*need to have the few lines of codes here*/
            if(entry.isDirectory()) {
              // Assume directories are stored parents first then children.
              System.err.println("Extracting directory: " + entry.getName());
              // This is not robust, just for demonstration purposes.
              (new File(entry.getName())).mkdir();
              continue;
            System.err.println("Extracting file: " + entry.getName());
            copyInputStream(zipFile.getInputStream(entry),
               new BufferedOutputStream(new FileOutputStream(new File("c:\\temp\\unzipping\\"+entry.getName()))));
          zipFile.close();
        } catch (IOException ioe) {
          System.err.println("Unhandled exception:");
          ioe.printStackTrace();
          return;
    }

    Given a file, you can create its parent directory like this:
    File outFile = new File("c:\\temp\\unzipping\\"+entry.getName())
    File parentDir = outFile.getParentFile();
    if (!parentDir.exists()){
      parentDir.makeDirs();
    }Not too hard is it?

  • How to POST (create) a folder using CMIS REST in Webcenter

    Has anyone tried to create a new folder using CMIS REST/Atom calls in Webcenter ?
    Here's what I try to do:
    http://172.31.100.150:7001/cmisrestprelim/cmis/children/MyContentServer ==>POST (using the REST client plug-in in Firefox)
    Content-Type=application/atom+xml
    <?xml version="1.0" encoding="utf-8"?>
    <entry xmlns="http://www.w3.org/2005/Atom"
    xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
    xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
    <title>mytestfolder</title>
    <cmisra:object>
    <cmis:properties>
    <cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>
    </cmis:properties>
    </cmisra:object>
    </entry>
    This piece of code should create a folder called "mytestfolder" in the root directory.
    When I POST this, I get the following internal server error:
    <pre>javax.servlet.ServletException: com.sun.jersey.api.container.MappableContainerException: com.bea.content.RepositoryException: Please specify a valid ID object. Make sure the repository name is not null.
         at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:310)
         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:314)
         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:239)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at com.bea.content.manager.servlets.ContentServletFilter.doFilter(ContentServletFilter.java:178)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
    Anyone has an idea how to solve this ?

    I must admit that I'm fairly new to all the CMIS and REST-things....
    So there are a couple of things in your answer that are a bit hazy to me.
    It looks like you are more familiar with all this.
    How do I find a creatable folder ? And what should be the URI to POST a new folder ?
    I try to POST a new folder using this URI:
    http://172.31.100.150:7001/cmisrestprelim/cmis/children/MyContentServer/IDC:Folder%2F13
    (IDC:Folder%2F13 is the /Contribution Folders/Documents folder in my repository)
    This POST keeps me giving the following internal server error:
    <pre>javax.servlet.ServletException: com.sun.jersey.api.container.MappableContainerException: com.bea.content.RepositoryException: Please specify a valid ID object. Make sure the repository name is not null.
         at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:310)
         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:314)
         at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:239)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at com.bea.content.manager.servlets.ContentServletFilter.doFilter(ContentServletFilter.java:178)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
    Thanks for helping me out.

  • Creating a Folder and uploading file into that folder Inside OneDrive in Office365 programmatically

    I am using this below code to create a folder inside onedrive in office365,but i cant able to access the url for accessing my personal onedrive,it causing error "Cannot connnect to the server"
     using (ClientContext clientContext = new ClientContext("https://claysys123-
    my.sharepoint.com/personal/anju_claysys123_onmicrosoft_com/Documents/Forms/All.aspx"))
                    SecureString passWord = new SecureString();
                    string currentyear = DateTime.Now.Year.ToString();
                    foreach (char c in "MyPassWord".ToCharArray()) passWord.AppendChar(c);
                    clientContext.Credentials = new SharePointOnlineCredentials("username", passWord);
                    Web web = clientContext.Web;
                    clientContext.Load(web);
                    clientContext.ExecuteQuery();
                    clientContext.Web.Folders.Add("https://claysys123.sharepoint.com/_layouts/15/start.aspx#/Shared%20Documents");
                    clientContext.ExecuteQuery();
    but whenever am executing this clientContext.Web.Folders.Add("https://claysys123.sharepoint.com/_layouts/15/start.aspx#/Shared%20Documents");
                    clientContext.ExecuteQuery(); causes Error "cannot Connect to The Server"..pls help me as soon as possible..
    please give me sample code to get rid of this problem.

    Creating folder in One drive is equivalent to communication with document library. Here are all the samples to create folder in document library.
    http://social.msdn.microsoft.com/Forums/silverlight/en-US/985bab38-7e81-498c-97d8-534e6ee4cf11/how-to-create-folders-based-on-logic-using-client-object-model-2013?forum=sharepointdevelopment
    Bala

  • How can I creat a folder by jsp

    import java.io.*;
    class folder
         public static void main(String args[])
              folder foIns = new folder();
              foIns.makeDir("E:\\test");
         public static void makeDir(String dir)
    File d = new File(dir);
    if (!d.exists()) {
    d.mkdir();
    I can creat a folder by java , but how can I creat a folder by jsp??
    thanks all ^_^

    import java.io.*;
    class folder
         public static void main(String args[])
              folder foIns = new folder();
              foIns.makeDir("E:\\test");
         public static void makeDir(String dir)
    File d = new File(dir);
    if (!d.exists()) {
    d.mkdir();
    I can creat a folder by java , but how can I creat a
    folder by jsp??
    thanks all place this class file in web-inf/classes of your web application,and in jsp page use
    <jsp:useBean id="fold" class="your complete class name" scope="page"/>
    <%
    fold.makeDir("dir name");
    %>

  • How to create mysql backup using java

    please i am trying to create a backup of my database using mysqldump with the runtime class. But it is not working out. Please can anyone give me a code that creates mysql backup in java?. I will be grateful.

    It might help to know what
    ushahemba wrote:
    it is not working outmeans.
    Please can anyone give me a code that creates mysql backup in java?.Now, I'm sorry, but why should anyone do your work for you?
    Read this thoroughly and conpletely, and implement the recommendations there.

  • Creating a folder in current workspace using java code

    Hi Experts,
    I need to create a folder and some file in the workspace of NWDS user. Can someone please suggest how can i find out the workspace of user using JAVA code.
    IWorkspaceRoot is not working in NWDS.
    Regards
    Pranav

    Hi Pranav,
    Tell me if you want to create this folder at run time or in NWDS while developing application.
    If you want to create it at the time of development just change your perspective to Java perspective and from there you can see the entire project structure and from there you can create desired files / folders.
    Ninad

  • Creating XML file in Project folder thru Java Program

    hi,
    i need one help. i need to create XML file in web://<Project Folder> in xmII thru Java Program. i created one java code and i am able to access XML file that is in c drive. i created jar file for this and placed as action block in Transaction and this working fine. but problem arises when i give file path in java code as web://<folder name>/file.xml which is in Web folder of project in xMII.
    How to access the file that is inside web folder from java code.
    regards
    senthil

    Hi Senthil,
    you can address the files that inside the MII workbench are viewed as "web://..." like this:
    http://<server>:<port>/XMII/CM/<Project>/<Folder>/<Filename>
    The workbench helps you find the correct filename:
    - open the WEB tab in the workbench
    - right-click on the filename
    - select "Copy Link" from the pop up
    Now you have the correct link in your clipboard.You can use the "web://" only inside MII.
    Michael

  • How to create a folder under BEA Repository through code

    Hi All,
    We are trying to create a folder under the BEA Repository through Java code. Could you please post the right API for it.
    We have tried the InodeManger class and its addNode method, which is good for creating any content, but we are trying to create the folder itself from the code.
    Thanks
    Veera

    Hi Veera,
    You're on the right track. The INodeManager.addNode method is the way to go. You just need to specify an object class name of a folder object class. Out of the box there's one, and this is configurable for your given repository's configuration. Once you add nodes of this type they'll be badged as folders in the portal admin tools.
    -Ryan

  • Create a folder(directory) in java

    i need to create a folder on a certain path on the hard drive from the java code..
    does anybody have an idea?

    Check out the File class

  • How to create a Folder Tree in Exchange Server from a Java progarm.

    hi all,
    I am using Microsoft Exchange Server 2000. I have a requirement of creating the following things from a Java program.
    1) Creating a Folder Tree
    2) Creating a Mailbox Store
    3) Creating a Public Store
    4) Creating a Recipient Policy
    5) Creating a Storage Group
    6) Creating a Mail-Enabled Recipient
    7) Adding a new UPN suffixes
    If any of you have worked on such requirement can you please provide me with some information regarding the same.
    Thanks & Regards
    Anil

    Any luck with this Anil?
    I would like to query exchange for the list or recipients on a given mailing list.
    Please inform if there is any documentation that may be helpful.

Maybe you are looking for

  • Trying to run a query

    I'm trying to run a query in a JTextField and then have that query display the output in a JTable. When I try to use .getText() to store the query in a string I keep getting errors about SQLException. Can anyone lend me in hand in telling me what I'm

  • Macbook Pro 1.83ghz Core Duo - Boot Disks

    Hello. I have misplaced my startup disk. Any chance I could paypal someone some money in order to get a burned copy mailed to me? The apple store doesn't have any. Thanks! Tom

  • Don't know how to get my iWeb websites to work in Mavericks. Need help!

    Trying to put my iWeb websites back on all my user accounts in their iweb folders from dvds' since i upgraded to mavericks. iweb keeps trying to open a brand new iWeb website. I thought if I just put them back in their iweb folders under each user ac

  • Sign asking for restart

    I have a problem with my new 13" macbook air. Randomly the screen gets grey and a sign prompts me to restart. What is wrong?

  • Sqldev 4 EA: ctrl-click not working

    ctrl-click for drilldown to objects form pl/sql code does not work. I get an annoying message to put my object in a "Select * from" statement. However this does not work either.