How to create file in specific folder...

Hi developers,
I am new to java. I would like to create file in some folder. But i am fail to create it. Can any body help me please..
This is my code. It creates folder well...But file doesn't create.
import java.io.*;
public class file1
     public static void main(String ar[])
          File f = new File("c:\\ram");
          f.mkdirs();
          String pat = f.getAbsolutePath();
          File ffs = new File("c:\\ram.txt");
          System.out.println(pat);
}With Regards
sure...:)-

Also, it's not clear where you want the file.
You're making a directory C :\ram, but then you're talking about a file ram.txt that's right in C:
Also, you can use / instead of doubling up the \ and it wil get converted properly.
If I wanted to create a file C:\ram\ram.txt I'd do this:
File parentDir = new File("C:/ram");
File file = new File(parentDir, "ram.txt");
parentDir.mkdirs();
file.createNewFile();

Similar Messages

  • How to Create File in another folder

    hi,
    I need to create a RandomAccessFile in Folder and that Folder was also created here if self only, so How it do this in a program.
    tname="xyz";
    String fname=tname+".xml";
    file = new File(fname);
    File dir=new File(tname);
    String path=dir.getAbsolutePath();
    System.out.println(path);
    if(dir.exists()==false)
    dir.mkdirs();
    I try to create xyz.xml file in xyz(folder name) itself, how can if be
    Thanking you,
    RaviVarma.K

    I'm not sure what you are trying to do but you seem to need
            File f = new File("the path of the file you want to create");
            f.getParentFile().mkdirs();No need to make the mkdirs() conditional since it will only make the directories if they don't exist.

  • How to create file with APDU

    Hello everybody,
    It's my first time using Java Card ^_^,I want to create a file and fill the fill with binary data.but i don't know how to create file with APDU commands,so I need help here.
    I think that there must be a Manual of the JavaCard's OS in this world,can someone tell me where to download it??
    Thanks.
    the fllowing is my card:
    Samsung S1
    Model:TiEx-32J
    EEPROM size:32k
    Platform Version:OP 2.0.1
    Card Manager Status:OP_READY
    KMC:40~4F/No derivation
    Message was edited by:
    AllenHuang

    If you look around the forum for a bit, you will see that there is no notion of file systems on JavaCards (lexdabear posted this information less than two hours ago :-)). To store files, you will have to write an applet to hold byte arrays of the required size and handle receiving and sending of these.
    As for documentation, you should have a look at the GP (General Platform) specification at http://www.globalplatform.org/, which defines communication between smart cards and other devices, as well as Sun's own JavaCard pages (http://java.sun.com/products/javacard/), which contain several useful resources on JavaCards.
    Message was edited by:
    Lillesand

  • To relocate mail.log, mail.log_current file to specific folder

    Hi
    We have configured CommSuite 6 in single host. The output of “imsimta version”:
    Sun Java(tm) System Messaging Server 7.0-0.04 32bit (built Jun 20 2008)
    libimta.so 7.0-0.04 32bit (built 01:01:00, Jun 20 2008)
    Using /opt/sun/comms/messaging/config/imta.cnf
    SunOS mail 5.10 Generic_120012-14 i86pc i386 i86pc
    Output of imta_tailor file:
    IMTA_USER=mailsrv
    IMTA_USER_USERNAME=nobody
    IMTA_WORLD_GROUP=mail
    IMTA_LOG=/logs/messaging/imta
    IMTA_PRIMARY_LOG=/logs/messaging/imta/mail.log_current
    IMTA_SECONDARY_LOG=/logs/messaging/imta/mail.log_yesterday
    IMTA_TERTIARY_LOG=/logs/messaging/imta/mail.log
    We need to relocate mail.log, mail.log_current, mail.log_yesterday file to specific folder.
    After above setting we cannot be able to relocate above file.
    Pl. help us.
    Thanks
    P.K.

    world.group wrote:
    We have configured CommSuite 6 in single host. The output of “imsimta version”:Please note that CommSuite 6 update 1 is now available and it is advisable that you upgrade using the "commpkg upgrade" command.
    IMTA_LOG=/logs/messaging/imta
    IMTA_PRIMARY_LOG=/logs/messaging/imta/mail.log_current
    IMTA_SECONDARY_LOG=/logs/messaging/imta/mail.log_yesterday
    IMTA_TERTIARY_LOG=/logs/messaging/imta/mail.logThese parameters are now ignored as per the Messaging Server 7.0 release notes:
    http://wikis.sun.com/display/CommSuite6/Messaging+Server+7.0+Release+Notes#MessagingServer7.0ReleaseNotes-Ignoredimtatailorsettings
    We need to relocate mail.log, mail.log_current, mail.log_yesterday file to specific folder. You can relocate the MTA log directory through the use of symlinks.
    Regards,
    Shane.

  • How to create file on application server?

    how to create file on application server?

    Hi,
    The following program illustrates the creation of ifle in app server and reading the file from appli server:
    DATA: ITAB LIKE vbakOCCURS 0 WITH HEADER LINE.
    PARAMETERS: P_VBELN LIKE VBAP-VBELN.
    START-OF-SELECTION.
      SELECT *
        FROM VBAP
        INTO TABLE ITAB
    WHERE VBELN = P_VBELN
        PERFORM WRITE_DATA.
        PERFORM READ_DATA.
    *&      Form  WRITE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_DATA.
    OPEN DATASET 'VBAP_DATA' FOR OUTPUT IN TEXT MODE.
    LOOP AT ITAB.
    TRANSFER ITAB TO 'VBAP_DATA'.
    ENDLOOP.
    CLOSE DATASET 'VBAP_DATA'.
    CLEAR: ITAB, ITAB[].
    ENDFORM.                    " WRITE_DATA
    *&      Form  READ_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM READ_DATA.
    OPEN DATASET 'VBAP_DATA' FOR INPUT IN TEXT MODE.
    DO.
    READ DATASET 'VBAP_DATA' INTO ITAB.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    APPEND ITAB.
    ENDDO.
    CLOSE DATASET 'VBAP_DATA'.
    LOOP AT ITAB.
    WRITE:/ ITAB-VBELN,
            ITAB-POSNR.
    ENDLOOP.
    ENDFORM.                    " READ_DATA
    If it is helpful rewards points
    Regards
    Pratap.M

  • How to create a directory or Folder  using java program?

    Hi all,
    Can any one know, how to create a directory(new folder) in java.
    can any give me some idea, on creating a directory using java program dynamically.
    thanx in advance

    hi thanks for your answer,
    sorry, actual i know this technique(its my fault i didnt mentioned it)
    i am looking for some what different technique.
    bye
    ram

  • How to create file menu in the swing?

    How to create file menu or any menu in the swing?
    Please help me.

    How to create file menu or any menu in the
    swing?
    Please help me.By file menu, do you mean where you can choose a file to open or save to? If so, have you had a look at the File Chooser component? If not, please click on the link in the previous sentence to the Sun tutorial.
    Good luck
    /Pete

  • How to create file system datagrid in flex web application

    how to create file system datagrid in flex web application

    Hi,
    Check this out:
    http://shigeru-nakagaki.com/flex_samples/FileReference/FileUploadExample2/FileUploadExampl e2.html
    Johnny
    Please rate answer.

  • How to create an application-specific policy file?

    Hi Everybody:
    I'm a .NET developer with C #. I have a few applications currently running on my computer using the ODP 10.1
    Two weeks ago I installed on my computer the ODP 10.2 Release & now my previous applications have stopped working: when I try to make the connection to the database gives me this exception:
    OraOLEDB (0x80004005)
    ORA-12154: TNS: could not resolve the connect identifier specified
    In FAQ section for ODP.NET I found the next:
    Q: I have two .NET applications on the same machine running two different versions of ODP.NET. How do I ensure both these applications use the correct ODP.NET version?
    A: Beginning with ODP.NET 10.1.0.3, the Oracle installer will register the following publisher policy DLLs in the Global Assembly Cache (GAC) that redirect 9.2, 10.1 and 10.2 ODP.NET applications to use the last installed version of ODP.NET: Policy.9.2.Oracle.DataAccess.dll and Policy.10.1.Oracle.DataAccess.dll.
    ODP.NET 9.2 includes just the first policy DLL above. These policy files ensure that all your ODP.NET applications use the most recently installed version of ODP.NET.
    You may undo the redirection manually. Policy DLLs can be de-installed through gacutil.exe using the /u option. Another approach is to navigate to the GAC directory (i.e. C:\WINNT\assembly) through the Windows Explorer and delete the policy folders. That will eliminate any policy enforcement for all your ODP.NET applications.
    If you have applications on the same machine using different ODP.NET versions, you should create an application-specific policy file.
    I'm trying to do that, but I don't know what is an application-specific policy file. Someone can give me an example of How can I create and application-specific policy file???
    Regards

    Hi,
    Binding redirection is a ".net thing" as opposed to a "odp.net thing", see if this helps:
    http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx
    Hope it helps,
    Greg

  • How to create files into a NT authentication folder

    Hi all,
    I know how to create txt files on a local computer. But is it possible to create files into a NT shared folder on server machine which is user/password protected?
    thanks,

    Hi,
    try it with SAPFTP.
    look:
    - sample RSFTP004
    - <a href="/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap">FTP</a>
    Andreas

  • How to count files in a folder and subfolders of the folder.

    Hello everyone,
    I'm having a difficulty with countin files in a Regular folder and subfolders of the folder. I've tried to use SI_ANCESTOR  in a query; however, it gives me innacurate results.
    I used this hierarchy to create the code below, and it works to count all the files:
    Folder A ---> Folder B( subFolder of A)  -
    > Folder C(subFolder of B)  
    //get folder A
    IInfoObjects regFolders = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND='Folder' AND SI_PARENTID=0 AND SI_NAME!='User Folders' Order by SI_NAME");
    IFolder regFolder = (IFolder) regFolders.get(0);     
    //get files from Folder A     
    IInfoObjects rFiles = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID !   = 'CrystalEnterprise.Folder'   AND SI_PARENTID=" + regFolder.getID() );
    ilesCount += rFiles.size();
    int subCntr=0;
    nt subCntr2=0;
      //get folder B      
    IInfoObjects rSubFolders = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Folder' AND SI_PARENTID=" + regFolder.getID() );
    //get files from subFolders of Folder A
    while (subCntr < rSubFolders.size())
              IInfoObject subFolder=(IInfoObject)rSubFolders.get(subCntr);
              IInfoObjects subFiles = infoStore.query ("SELECT * FROM CI_INFOOBJECTS "
          + " WHERE SI_PROGID != 'CrystalEnterprise.Folder'" AND SI_PARENTID=" + subFolder.getID() );
             filesCount += subFiles.size();
             //get subFolders of Folder B                   
             IInfoObjects rSubFolders2 = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Folder' AND SI_PARENTID=" + subFolder.getID() );
                         //get files from subFolders of Folder B
         while (subCntr2 < rSubFolders2.size())
              IInfoObject subFolder2=(IInfoObject)rSubFolders2.get(subCntr2);
              IInfoObjects subFiles2 = infoStore.query ("SELECT * FROM CI_INFOOBJECTS "
                   + " WHERE SI_PROGID != 'CrystalEnterprise.Folder'  AND SI_PARENTID=" + subFolder2.getID() );
                                               filesCount += subFiles2.size();
               subCntr2++;
              subCntr++;
    As you can see, the code is too complicated, and what if folder C has subFolder?
    I'm guessin maybe recursion would be one way to got, but I'm not really good with it, so I was wondering if anyone has any idea on how to go about doing it.
    Thank you,

    Hi,
    For detailed information, please refer to the BI 4.0 developers guide here.
    You can find the section "Setting up the development environment" in developers guide that have every single instruction to execute a java code specific to BI 4.0 environment.
    Also, here are the instructions for BO 3.1 environment:
    To configure a WAR file for a J2EE application that uses the BusinessObjects Enterprise XI 3.0 and 3.1 Java SDK, complete these steps:
    Create a lib folder in the WAR file's WEB-INF folder.
    Copy the Enterprise XI 3.0 or 3.1 Java SDK JAR files from the appropriate location below to the WAR file's WEB-INF\lib folder:
    Windows:
    ...\Program Files\Business Objects\common\4.0\java\lib
    UNIX:
    <businessobjects_root>/java/lib
    Copy the log4j.jar file from the appropriate location below to the WAR file's WEB-INF\lib folder:
    Windows:
    ...\Program Files\Business Objects\common\4.0\java\lib\external
    UNIX:
    <businessobjects_root>/java/lib/external
    Copy the entire crystalreportviewers12 folder from the appropriate location below to the WAR file's root folder.
    Windows:
    ...\Program Files\Business Objects\common\4.0
    UNIX:
    <businessobjects_root>/enterprise12/JavaSDK
    Open the web.xml file located in the WAR file's WEB-INF folder.
    Specify the location of the utility files used by the report viewers contained in the crystalreportviewers12 folder by inserting the following code below the <display-name> and <description> tags but within the <webapp> tag definition:
    <context-param>
    <param-name>crystal_image_uri</param-name>
    <param-value>/BOXIR3/crystalreportviewers12</param-value>
    </context-param>
    <servlet>
    <servlet-name>CrystalReportViewerServlet</servlet-name>
    <servlet-class>com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>CrystalReportViewerServlet</servlet-name>
    <url-pattern>/CrystalReportViewerHandler</url-pattern>
    </servlet-mapping>
    Deploy the WAR file to the J2EE application server.
    You are now able to run an application using the BusinessObjects Enterprise XI 3.0 and 3.1 Java SDK on a J2EE web application server.
    Hope it helps.
    Regards,
    Anchal

  • How to creat a Password Protected Folder

    Hi
    I was wondering how do I create a single folder that contains all of my passwords (Banking ...etc) that only I have access to - I would like to password protect this foder and if possible have the information inside encripted.
    I was looking into security vault - but I'm afraid it encripts all the folders on my Mac. I just want to create a single folder - everything else should be as it was.
    Any help is greatly appreciated
    Thanks

    Create a password-protected (encrypted) disk image
    1. Open Disk Utility at /Applications/Utilities.
    2. Images>New>Blank Image... or click the "New Image" button in the Toolbar.
    • go to step 3
    2a. To encrypt an existing folder..
    • Go to...Images>New>Image from Folder.
    • In the dialog window, select the folder and press "Open"
    3. Type and/or select from popup window .....
    • Name • location • Format
    • Size (no size option for folder)
    • Encryption .....AES-128 must be selected
    4. Click the "Create" button ..... or if Image from folder was used, click "Save"
    5. Enter and verify your password when prompted and click "OK".
    6. The .dmg will appear on the desktop and the left pane of Disk Utility.
    •Important...If you forget the password, the data stored will be lost.If you save your password in the keychain file, it will be available to you there.
    An easy way to password-protect certain folders
    To password protect a specific folder in any version of OS X, if you're an administrator, simply change the permissions in the "Get Info" box so that the folder is owned by the system. You'll be prompted for a password. To access the folder again, just change the ownership back - and it will require a password to be made accessible.
    Secret Folder lets you conceal a folder and its contents.
    http://apimac.com/secret_folder/index.php

  • Query Count files under Specific folder in Sccm?

    Hello!
    I try to create a Query in sccm. There I want to count files under a specific folder. If folder on the client have less than 35 files, show the name of that computer. How should I begin to create that Query? Should I use criteria Software files Count?
    Greetings
    Emil

    I think for this task you will find it easier to create a report instead. Queries are based on WQL which has some limitations.
    Kent Agerlund | My blogs: blog.coretech.dk/kea and
    SCUG.dk/ | Twitter:
    @Agerlund | Linkedin: Kent Agerlund |
    Mastering ConfigMgr 2012 The Fundamentals

  • How to create files with read/write privileges for everyone?

    I have two iMacs 7,1 (one with Snow Leopard and the other with Mountain Lion) in a local area wireless network.
    I have shared the "documents" folder in the Snow Leopard iMac in order to have files available to the other iMac. The folder has read/write privileges for everyone.
    When I create a new file in the shared "Documents" folder (for example a new Open office document, or a Keynote presentation) this file is by default "read/write" for the Administrator but only "read" for all the other users, so when I try to open it from the other iMac, I am informed that the file is "read only".
    I can obviously change the privileges of the file in the information window, but I have to do on a file per file basis and this takes too long.
    Is it possible to change settings in order to create files which are always "read/write" for everyone?
    And, secondly, since I have several existing files whose privileges I should manually change one by one, is it possible to make global changes of their privileges?
    Thanks in advance
    Best regards

    couple of different changes - 1st, if you want to share folders, doing your whole documents folder is not the best way.  Since both your computers can handle AidDrop, that's what I would recommend - http://osxdaily.com/2011/11/14/how-to-use-airdrop-in-mac-os-x/ - as it create an instant Ad-Hoc network between the two computers and then let's it done. 
    A second possibility that may not be what you're looking for, is to use google drive or some similay cloud sharing app to sync the documents back and forth.  both of these solutions will transfer the files well, but the airdrop may be simplest

  • How to create an association in folder options panel in order to open an e mail

    when trying to open attachment, it tells me that this file does not have a program associated with it to perform this action.
    I have to create an association in folder options panel.
    how do i do that?

    See this: <br />
    http://support.mozilla.com/en-US/kb/Managing+file+types

Maybe you are looking for