Create folder in current directory

Hi all,
I would like to be able to create a folder through my java program, in the current directory that the java program is in.
Furthermore, I do not want to have to change any code if the java program is suddenly moved to a different folder.
Something like this, but obviously currentDirectory would have to actually be the specific directory that the program is in:File f = new File(currentDirectory);
f.mkDir();Also, just on a side note if anyone has any knowledge of MySQL, I would like to be able to do this when using 'batch mode' and pointing a batch file to a text file containing mysql commands:
mysql -u root -p < d:\mysql\jdbc\createdatabase.txtso the current directory would replace 'd:\mysql\jdbc\'.
thanks very much

Hi Jon
On the first topic, try this.
import java.io.File;
public class MakeDir {
     public static void main(String[] args) {
          if (args.length != 1 || args[0] == null || args[0].trim().length() == 0) {
               System.out.println("Usage: java MakeDir <folder name>");
               System.exit(-1);
          File f = new File(System.getProperty("user.dir") + "\\" + args[0]);
          f.mkdir();
}/John

Similar Messages

  • Create folder in Integration Directory - Can not be uniquely addressed

    Hi experts,
    I have the following issue. When creating a folder in Integration Directory I get a warning info, like the following:
    E.g. folder name should be "test"
    "The folder test could not be uniquely addressed by the path /test/ because two or more folders share the same name"
    I checked the repository for another folder with the same name but without success.
    The point is, that I want to use the API to add objects to the folder. But without a unique address the creation will fail.
    What makes this very strange is, that sometimes it works.
    Is there any place in the repository where folder ids can be checked for uniqueness ?
    Thanks a lot.
    Timo

    Hi Jon
    On the first topic, try this.
    import java.io.File;
    public class MakeDir {
         public static void main(String[] args) {
              if (args.length != 1 || args[0] == null || args[0].trim().length() == 0) {
                   System.out.println("Usage: java MakeDir <folder name>");
                   System.exit(-1);
              File f = new File(System.getProperty("user.dir") + "\\" + args[0]);
              f.mkdir();
    }/John

  • How to create file in current directory?

    In my JSP-page I tried to create some file in my current project directory but this file is created in C:\jakarta-tomcat-4.0.1\bin directory. I can do it using absolute path but I'd like to use relative path. Please help me.
    Thank you in advance.
    Qand.

    Try this:
    String filename = servletContext.getRealPath(request.getContextPath());Then take off the last part (after the last slash) and put on your temporary file name.
    It's a thought, anyway...

  • How to create a file in current directory

    hi,
    I want to create a file in a current directory, But when i written following
    code then it cannot create file, How i will create file in current directory?
    Is there anyone who can help me?what will be the solution of this problem?
    Please give me solution
    String dir=application.getRealPath("/");
         int count;
         String filename="sample.txt";
         out.println(dir+filename);
         FileOutputStream fout=new FileOutputStream(filename);
         PrintStream p;
         p=new PrintStream(fout);
         p.print("1");
         p.close();with regards
    Bina

    hi,
    my problem is that my path is ok...but when i open file in this directory then
    it cannot open a file, is there anyone who can do it? When a user save data in server from remote
    area then what will be path of my code? how i will solve it? please give me
    solution.
    with regards
    bina

  • How to create a file in server's current directory

    hi,
    I have a project, but when i will run my program on internet Explorer then
    it will create a folder in server's current directory, but i will not specify
    drive & folder, it will create a folder in server's current directory, after that
    i will read file from that, what will be the solution of this ? Is there
    anyone who can give me solution? PLease help me
    With regards
    Nahar

    ServletContext context = session.getServletContext();
    String realContextPath = context.getRealPath(request.getContextPath());this will give you access to the servlets current directory
    from there you can create a file
    I dont know how much this will help

  • Error 7 occurred at Create Folder in Create Directory Recursive.vi-

    Recieved following message when attemoting to create source distribution
    Error 7 occurred at Create Folder in Create Directory Recursive.vi->ABAPI Dist Create Directory Recursive.vi->ABAPI Dist Chk for Destinations.vi->ABAPI Copy Files and Apply Settings.vi->SDBEP_Invoke_Build_Engine.vi->SDBUIP_Build_Invoke.vi->SDBUIP_Build_Rule_Editor.vi->SDBUIP_Item_OnDoProperties.vi->SDBUIP_Item_OnDoProperties.vi.ProxyCaller
    Possible reason(s):
    LabVIEW:  File not found. The file might have been moved or deleted, or the file path might be incorrectly formatted for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux.

    Hello,
    Could you please list which options you are selecting when building a
    source distribution (I am assuming you are using LabVIEW 8.0?).
    Do you get this error when clicking on "Generate Preview" button when configuring source distribution properties?
    Under "Distribution Settings" category, could you try checking the
    "Disconnect type definitions and remove unuses polymorphic VI
    instances" option and see if that helps with the build process?
    Also I suggest Mass Compiling your VIs (Tools -> Advanced -> Mass Compile) before creating a source distribution.
    If these do not help, could you attach your project with all the VIs it contains here?
    Thank you and best regards,
    Shakhina P.
    Applications Engineer
    National Instruments

  • Create folder and move files to specific directory in AL11

    My requirement is to create a new folder in one of the existing directories in AL11 and move some files into it.
    I searched the forum and found this solution but it creates folder only in DIR_HOME directory.
    data: unixcom like rlgrap-filename.
    data: begin of tabl occurs 500,
    line(400),
    end of tabl.
    unixcom = 'mkdir mydir'. "command to create dir
    "to execute the unix command
    call 'SYSTEM' id 'COMMAND' field unixcom
    id 'TAB' field tabl[].
    I want the folder to be created in some other directory DIR_INTERFACES .
    Any suggestions are welcome ..

    Get complete path (physical path) using FM FILE_GET_NAME_USING_PATH.
    Default directory is DIR_HOME, hence it creates file in that directory...If you specify complete folder name, it will be created under that path..
    Concatenate mkdir
    space
    <physical path>
    mydir
    into unixcom.

  • Error 1430 occurred at Create Folder in Create Directory Recursive.​vi

    Hi all..
    I am facing the error which stated :
    Error 1430 occurred at Create Folder in Create DirectoryRecursive.vi->AB_Destination.lvclass:Crea​te_Destination.vi->AB_Build.lvclass:Create_Destina​tions.vi->AB_Application.lvclass:Create_Destinatio​ns.vi->AB_Build.lvclass:Build.vi->AB_Application.l​vclass:Build.vi->AB_EXE.lvclass:Build.vi->AB_Build​.lvclass:Build_from_Wizard.vi->AB_UI_Frmwk_Build.l​vclass:Build.vi->AB_UI_FRAMEWORK.vi->AB_Item_OnDoP​roperties.vi->AB_Item_OnDoProperties.vi.ProxyCalle​r
    Possible reason(s):
    LabVIEW:  The path isempty or relative. You must use an absolute path.
    <Not A Path> 
    I have been trying to do all solutions given by error 6 such as check the  disconnect type definition and remove unused polymorphic VI instances, generate the absolute path and etc. However the same error still occured.
    Please advise guys~ I'm using LabView 2009. 

    I'm having the same problem when trying to build a RT executable.  
    I'm using the FTP Put Buffer.vi along with a data to string example I found on the NI website. I can build the executable when I use a constant instead of the data to string but I can't for the life of me figure out why.
    Order of pictures:
    dataftp.png, which shows the data to string connecting to the data input on the FTP Put Buffer.vi.
    vars.png,which shows thevars being placed into an array and connecting to the Convert to String vi.
    convert.png, which shows the guts of the convert to string vi.
    Attachments:
    dataftp.png ‏2 KB
    vars.png ‏5 KB
    convert.png ‏7 KB

  • Publish site changes edits every folder in "entries" directory

    I utilize Lytebox slideshows in my blog entries and have an issue with MobileMe erasing the necessary Lytebox files from every blog Entries directory (Web/Sites/Site Name/Site Name/Entires/Year/Month).
    I always update my website via Files>Publish Site Changes. I publish to MobileMe so that I can make my site private.
    I expect MobileMe to overwrite the files in the Entries folder for the specific blog entry I have created/changed, but why are the Lytebox files erased from every single Entries folder? I just did a test by making a minor change to a blog entry, publishing site changes and then using Cyberduck to check the Entries directory. Sure enough, every folder in that directory was modified.
    As a result, every time I make any changes to my website, I have to upload the Lytebox files to every Entries folder, currently I have 15 of them.
    Any reason MobileMe is doing this? Can I avoid this from happening? If not, I'll post another question about how to quickly and automatically upload the lytebox files to every Entries folder.
    Thank you.

    Any 3rd party files/folders used for java based slideshows in an iWeb site should be placed in the iDisk/Web/Sites folder and linked to there and NOT in the site's folder itself for the very reason you're experiencing. That is, they get deleted when the site is republished. It's the nature of iWeb.
    You should use the following URL to link to a particular file in the Lytebox folder (assuming that folder is named Lytebox): http://web.me.com/MobileMeAccount_Name/Lytebox/Filename.
    OT

  • Need some help with putting a folder in users directory

    I'm not sure how to do this, but what I want to do is put this file in C:/My Documents, but I need to be able to verify that C://My Documents exists, if not put it in C:/Program Files.
    Can any one help me out?
    try {
                        String[] contactArray = parseDatFile(fc.getSelectedFile());
                        Document document = createXMLDocument(contactArray);
                        saveToXMLFile(
                        document,
                        new File(
                        "C:/Program Files/xxx/",// looks for directory for list
                        "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
                    } catch (Exception exc) {
                        File f = new File("C:/Program Files/xxx/");// setting directory for list if not there
                        boolean yes = true;
                        yes = f.mkdir();// creating directory
                        try {
                            String[] contactArray = parseDatFile(fc.getSelectedFile());
                            Document document = createXMLDocument(contactArray);
                            saveToXMLFile(
                            document,
                            new File(
                            "C:/Program Files/xxx/",// used only if the directory didn't exist
                            "xxxxxxxxxxxxxxxxxxxxxxx"));

    Need some help with putting a folder in users directoryI recomend using System.getProperty( "user.home" ) not a hard-coded value.
    This will use the users home folder ( C:\My Documents ) on Win9X (I guess), C:\Documents and Settings\<current user> on Win2K +, and ~ on Unix-a-likes.

  • Group Policy Logon Script to create folder based on username, run as admin

    Hello,
    I'm at a loss as to how to make this work.  I wrote the following PowerShell script that will check to see if the currently logged in user has a folder on a share, and if not it will create the folder and set appropriate permissions.  I want to
    run it as a Group Policy Logon Script, however I need to run this script as an administrator because users don't have any write/create access at the folder level of the file share.  The problem with that then becomes $ENV:Username resolves to the admin
    account the script is running under.
    Any ideas?
    Thanks!
    Ryan
    # Declare Variables
    $strName = $env:USERNAME
    $strDomain = $env:USERDOMAIN
    If ($strDomain -eq "domain.org") {
    # Split Username into 2 variables
    $data = $strName.Split("_")
    $fname = $data[0]
    $lname = $data[1]
    #Find first character of last name
    $firstcharacter = $lname[0]
    # Figure out if last name begins with A-M or N-Z
    $A_M=$firstcharacter -match "[a-m]"
    $N_Z=$firstcharacter -match "[n-z]"
    # Checks to see if folder exists
    If ($A_M -eq $true){$FolderExists = Test-Path "\\staff-files\staff\Last Name A-M\$strName"}
    elseif ($N_Z -eq $true){$FolderExists = Test-Path "\\staff-files\staff\Last Name N-Z\$strName"}
    # Creates folder if it doesn't exist
    If (($FolderExists -eq $false) -and ($A_M -eq $true)){
    New-Item "\\staff-files.domain.org\Staff\Last Name A-M\$strName" -type directory
    $DirPath = "\\staff-files.domain.org\Staff\Last Name A-M\$strName"
    elseif (($FolderExists -eq $false) -and ($N_Z -eq $true)){
    New-Item "\\staff-files.domain.org\Staff\Last Name N-Z\$strName" -type directory
    $DirPath = "\\staff-files.domain.org\Staff\Last Name N-Z\$strName"
    ElseIf ($strDomain -eq "students.domain.org") {
    # Pull 2 digit year from username and make 4 digit year
    $4digityear = "20" + $strName.Substring(0,2)
    # Checks to see if folder exists
    $FolderExists = Test-Path "\\files.domain.org\students\$4digityear\$strName"
    # Creates folder if it doesn't exist
    If ($FolderExists -eq $false) {
    New-Item "\\files.domain.org\students\$4digityear\$strName" -type directory
    $DirPath = "\\files.domain.org\students\$4digityear\$strName"
    # Assign Permissions
    If ($FolderExists -eq $false){
    $target = $DirPath
    $acl = Get-Acl $target
    $inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
    $propagation = [system.security.accesscontrol.PropagationFlags]"None"
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("CREATOR OWNER","Modify",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("NT AUTHORITY\SYSTEM","FullControl",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("administrators","FullControl",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    If ($strDomain -eq "students.hempfieldsd.org"){
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("DOMAIN\Domain Users","Modify",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("DOMAIN\Staff_Tech","FullControl",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ("DOMAIN\Enterprise Admins","FullControl",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $accessrule = new-object system.security.AccessControl.FileSystemAccessRule ($strName,"FullControl",$inherit,$propagation,"Allow")
    $acl.AddAccessRule($accessrule)
    $acl.SetAccessRuleProtection($true,$false)
    $acl.SetOwner([System.Security.Principal.NTAccount]$strName)
    Set-Acl -AclObject $acl $target
    Ryan Breneman - Systems Administrator - Hempfield School District

    Thanks jrv.  That is kind of what I thought but wasn't sure.  I think I will attack this a different way and modify the script to run through all the AD accounts and check for folder existence and create if needed.  Perhaps I'll play
    with System Center Orchestrator and run it inside there.
    These folders aren't being used for profile storage, and we already have folder redirection pointing to them, however I don't want a user to login to citrix and not have anywhere to save if they didn't have a folder to redirect to.
    Folders are supposed to be created when the staff member/student AD account is created, but it doesn't always happen.
    Thanks for your help!
    Ryan Breneman - Systems Administrator - Hempfield School District

  • Can Dreamweaver create the remote root directory?

    Hi,
    Does Dreamweaver have the capability to create the remote
    root directory? As an example, if I define a remote site and I set
    the host directory to public/site3 where the public directory
    already exists on the server but site3 directory does not, can
    Dreamweaver create the site3 folder? Other programs will notify
    that the directory does not exist and ask if you'd like for it to
    be created. Dreamweaver just seems to give me error messages.
    I'm currently using a straight FTP program to create the
    directory before I define the remote site but it seems ridiculous
    to have to do this.
    Thanks!
    Julie

    > can Dreamweaver create the site3 folder?
    Sure.
    But - what do you expect this to do for you? Are you trying
    to have
    multiple sites on a single hosting account?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "[email protected]"
    <[email protected]> wrote in message
    news:fbutc7$88f$[email protected]..
    > Hi,
    >
    > Does Dreamweaver have the capability to create the
    remote root directory?
    > As
    > an example, if I define a remote site and I set the host
    directory to
    > public/site3 where the public directory already exists
    on the server but
    > site3
    > directory does not, can Dreamweaver create the site3
    folder? Other
    > programs
    > will notify that the directory does not exist and ask if
    you'd like for it
    > to
    > be created. Dreamweaver just seems to give me error
    messages.
    >
    > I'm currently using a straight FTP program to create the
    directory before
    > I
    > define the remote site but it seems ridiculous to have
    to do this.
    >
    > Thanks!
    > Julie
    >

  • Getting current directory from an applet

    Hi. How can I get the current directory of my applet running on web without having to worry about permissin. I used the one below:
    curDir = System.getProperty("user.dir");
    but I get this error:
    ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
    any substiture for this? Thanks.

    You should be using URLs or similar approaches, and avoiding File, which will
    never work with an ordinary applet.
    InputStream in = this.getClass().getResourceAsStream("file.txt");That assumes the txt file is in the same place as the current classes .class file.
    For example, the same folder or that they are jarred in the same "folder" in the jar.
    You can also use a URL directly:
    URL url = ...
    InputStream in = url.openStream();and you can construct that URL with the help of Applet methods getDocumentBase or getCodeBase:
    URL url = new URL(this.getDocumentBase(), "file.txt");That assumes the txt file is in the same folder as the html file in which the applet is embedded.

  • How can I make an applet look to the current directory to read a txt file in?

    I am using a File class passing only the file name as the contructor but forte still looks in "C:\forte_jdk\forte4j\bin\Events.txt" which is not my current directory for the project.
    If leave it and ftp this applet to my web site I get an IOException.

    I always find visual aids helpful. See below for screenshots & discriptions.
    01. The Basics
    When you create a new site & go into design view (in the example below it's the Home page), you'll see the following.
    The white box is your page.
    The grey box outside of that is your browser area.
    The black & white checkered area is the Adobe Muse CC application chrome.
    02. Add Box
    Draw / Add your rectangle or text frame (text tool). I drew a rectangle, gave it a fill color of blue & turned the stroke from 1 to 0.
    03. Extend & Snap to Browser Edge (Left)
    Click, hold  and drag your mouse on the center adorner (adorner is the little squares that you can grab to resize your rectangle) until you resize your rectangle to the browser edge (the dark grey area) until you see a red line. This means you've 'snapped' one of the rectangle's edge to the browser edge.
    04. Extend & Snap to Browser Edge (Right)
    Repeat the process except do this for the right edge. In truth, it doesn't matter in which order you resize your rectangle to snap to the browser edges. The key thing is to be sure to do this for both sides of the rectangle & snap it to the browser edge (see the red line).
    05. You're done! Preview.
    06. Bonus!
    Once again, you can make rectangles or text frames 100% width, BUT you can't do this with placed images.
    However, you can do this with a rectangle or text frame. Then set the Fill of either the rectangle & text frame to be an Image & set the Fitting to 'Scale to Fill.'
    (see below for example - I used a rectangle & changed it's Fill property)
    Now when I preview, the image is 100% width. In truth, it's a 100% width rectangle with a fill of an image.

  • How to  add a folder in unix directory?

    how to  add a folder in unix directory?
    /usr/zz00/zz/mm/..
    i need one more folder
    /usr/zz00/zz/mm/addfolder/text.txt..

    No way with pure ABAP. Either contact your unix adminstration or create a logical system command in SM69/SM49 which can be called via call function 'SXPG_CALL_SYSTEM'

Maybe you are looking for