Creating a Directory with Java

Posted by spiraldev, Posted on June 1, 2009 I was playing around today and I found out how to create a new directory with JAVA I still prefer the cfDirectory
  1. Comments
  2. marc esher wrote on 06/02/09 3:48 AM

    I think the real benefit to going the java route isn't in the day-to-day "create a single directory" example, which is so easy in CF. The real power comes from mkdirs(), which makes it really easy to create a directory including any nonexistent parents.

    if you have /mydir/, and you want to create /mydir/subdir1/subdir2/subdir3, you'd have 3 separate calls in CF. But going the java route, you just use virtually the same code as in your example: xxx.init("/mydir/subdir/subdir2/subdir3").mkdirs()
    1. Comments
    2. Eric Cobb wrote on 06/02/09 6:31 AM

      I second Mark's comment. I recently wrote a blog post on using Java to create files and directories, which uses mkdirs() to create multiple directories at once. (http://www.cfgears.com/index.cfm/2009/5/19/Tapping-in-to-ColdFusions-underlying-Java-capabilities)
      1. Comments
      2. spiraldev wrote on 06/02/09 7:51 AM

        Marc thanks for pointing out mkdirs() I didn't see it the first time I dumped CreateObject("java","java.io.File").init(JavaCast("String",expandPath(sDir)));
        now after seeing mkdirs() I think I like the JAVA method better. The main reason is that I don't have to check to see if a directory exists first, unlike cfdirectory if you try to create a directory that already exists you get an error.
        1. Comments
        2. oyun wrote on 10/09/09 9:21 AM

          Java is enough fast to create a directory and secure
          1. Comments
          2. peynir wrote on 11/04/09 5:40 PM

            I'm really very useful to follow a long-time see this as a blog here Thank you for your valuable information.
            1. Comments
            2. oyun wrote on 12/24/09 1:00 PM

              I'm really very useful to follow a long-time see this as a blog here Thank you for your valuable information.
              1. Comments
              2. goldpreis wrote on 03/05/10 5:15 AM

                I don't have to check to see if a directory exists first.

                thanks.
                1. Comments
                2. LeanneMassey wrote on 03/07/10 1:47 PM

                  Don't you acknowledge that this is correct time to get the <a href="http://lowest-rate-loans.com">loans</a>;, which will help you.
                  1. Comments
                  2. buy essays wrote on 04/02/10 12:54 AM

                    It's not so simply to make a excellent essays written, especially if you are booked. I give advice you to find buy custom essay papers and to be devoid from distrust that your work will be done by writing service
                    1. Comments
                    2. buy term papers online wrote on 04/04/10 9:00 AM

                      All the time, different students, which really require the custom write essay, don’t know how to get that. But it can be not hard to buy an essay at the professional writing service. That’s a natural action for most students.
                      1. Comments
                      2. buy an essay wrote on 04/09/10 10:15 AM

                        Very charismatic event about this good topic, but still this question is to not an easy task to debate.That is why we have mastered to create a custom writing service to help striving students. They can buy term papers that is custom and made by professional , buy essays or even buy research papers. But when customers use this kind of services – an ethical question is raised: Is it ok to use these kinds of services? Is it ok to use them, and will you be punished for using them.
                        1. Comments
                        2. case study writing wrote on 04/11/10 6:31 AM

                          University studying process requires advanced writing skills, but, students, which are short of time can destroy their career. Thence, to order the business term paper from the essay writing online service should be a perfect solution.
                          1. Comments
                          2. buy dissertation wrote on 05/04/10 10:41 PM

                            The information you provided is quite simple and clear for knowledge seeker. Thanks for your research anyways.
                            1. Comments
                            2. koxp wrote on 08/10/10 4:37 PM

                              thank you admin articlles
                              1. Comments
                              2. writing jobs wrote on 08/13/10 6:41 AM

                                All go to academic writing jobs service, with the aim to required facts about this topic.
                                1. Comments
                                2. drug detox wrote on 08/26/10 12:36 AM

                                  I opine, it is truth that only certified custom corporations are able to provide good support. Moreover, that is no risk when you buy college research paper from specialists!
                                  1. Comments
                                  2. homework help wrote on 09/06/10 11:02 AM

                                    Give me an advice if that is workable to receive the ancient essays paper at the papers writing services, or probably it is better to order essay for cheap?
                                  3. Write your comment



                                    (it will not be displayed)