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.

Similar Messages

  • 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();

  • 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 copy file to another server from database using FTP in oracle

    How to copy file to another server from database using FTP in oracle.
    Please do the needfaul.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Not to mention that some FTP servers can return more than one return message per operation whereas others may return one message for the same operation.I had the problem using the LIST command to determine if a file exists on the server. Cannot be determined via the FTP server's return code. Which means parsing and checking the text response from the server to the command. And this vary from server to server.
    But the basics were quite easy to code. The entire package is 500 lines, includes comments and blank lines for formatting, and supports the basic FTP client command set. Not really a complex piece of software to write - but I found that many developers seem to think that writing network socket software is complex. Not really the case...Mine's a big larger, but incorporates functionality similar to what Chris provided in his, such as being able to use SQL to query a remote file using pipelined functions, or functionality to write the results of a query directly to a remove file.
    :)

  • 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 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

  • 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 move files from one folder to another folder in webdynpro java for sap portal

    Dear Experts,
    I wan to move files from one folder to another folder in SAP portal 7.3 programmatically in webdynpro java.
    My requirement is in my portal 1000 transport packages is their. Now i want to move 1 to 200 TP's into Archive folder.
    Can you please help me how to do in through portal or wd java ...
    Regards
    Chakri

    Hello,
    Do you know what the difference between copying a file this way :
    ** Fast & simple file copy. */
    public static void copy(File source, File dest) throws IOException {
    FileChannel in = null, out = null;
    try {         
    in = new FileInputStream(source).getChannel();
    out = new FileOutputStream(dest).getChannel();
    long size = in.size();
    MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
    out.write(buf);
    } finally {
    if (in != null) in.close();
    if (out != null) out.close();
    ================SECOND WAY============
    AND THIS WAY:
    // Move file (src) to File/directory dest.
    public static synchronized void move(File src, File dest) throws FileNotFoundException, IOException {
    copy(src, dest);
    src.delete();
    // Copy file (src) to File/directory dest.
    public static synchronized void copy(File src, File dest) throws IOException {
    InputStream in = new FileInputStream(src);
    OutputStream out = new FileOutputStream(dest);
    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    in.close();
    out.close();
    And which is better? I read up on what each kind of does but still a bit unclear as to when it is good to use which.
    Thanks in advance,
    JavaGirl

  • 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 do you delete folders in word? I made some folders but did not realize I had created them within another folder. Also, how do you create folders correctly?

    Please help! Thanks

    Hi Aristotle222,
    Welcome to the Support Communities!
    Files and folders are created by the Macintosh OS, not a specific application.
    The link below will explain how to create folders and subfolders, and organize your data using Finder.
    Mac Basics: Applications, files, and folders (OS X Lion)
    http://support.apple.com/kb/HT2476
    Cheers,
    Judy

  • 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

  • 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 store files in shared-folder in background mode

    Hello All,
    My requirement seems to be simple but I have tried many ways in achieving this, but failed. So require the help in accomplishing this task.
    Requirement
    I have to create a program in SE38 which will create a internal table with data in it in .XML format(which I can achieve).
    My requirement is this .XML file needs to be placed in a shared-folder in "BACKGROUND MODE".
    I have tried using GUI_DOWNLOAD function module, but this FM only runs in Foreground mode and fails in Background mode. I have tried convincing my client that I will keep the file in Application Server as it is achievable using OPEN DATASET statements, but they are not willing to accept this.
    So can you please help me in achieving this task as I am not getting any solution how to keep the file in Shared-folder in BACKGROUND mode itself(not Foreground).
    Best Regards,
    Tousif

    Hi Sanjeev,
    I have just used normal GUI_DOWNLOAD FM. Please find my sample code below
    CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
    *       BIN_FILESIZE                    =
           filename                        = 'D:\Users\baigtomx\Desktop\TOUSIF.XML'
    *       FILETYPE                        = 'ASC'
    *       APPEND                          = ' '
    *       WRITE_FIELD_SEPARATOR           = ' '
    *       HEADER                          = '00'
    *       TRUNC_TRAILING_BLANKS           = ' '
    *       WRITE_LF                        = 'X'
    *       COL_SELECT                      = ' '
    *       COL_SELECT_MASK                 = ' '
    *       DAT_MODE                        = ' '
    *       CONFIRM_OVERWRITE               = ' '
    *       NO_AUTH_CHECK                   = ' '
    *       CODEPAGE                        = ' '
    *       IGNORE_CERR                     = ABAP_TRUE
    *       REPLACEMENT                     = '#'
    *       WRITE_BOM                       = ' '
    *       TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *       WK1_N_FORMAT                    = ' '
    *       WK1_N_SIZE                      = ' '
    *       WK1_T_FORMAT                    = ' '
    *       WK1_T_SIZE                      = ' '
    *       WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    *       SHOW_TRANSFER_STATUS            = ABAP_TRUE
    *       VIRUS_SCAN_PROFILE              = '/SCET/GUI_DOWNLOAD'
    *     IMPORTING
    *       FILELENGTH                      =
         TABLES
           data_tab                        = lt_wo
    *       FIELDNAMES                      =
    *     EXCEPTIONS
    *       FILE_WRITE_ERROR                = 1
    *       NO_BATCH                        = 2
    *       GUI_REFUSE_FILETRANSFER         = 3
    *       INVALID_TYPE                    = 4
    *       NO_AUTHORITY                    = 5
    *       UNKNOWN_ERROR                   = 6
    *       HEADER_NOT_ALLOWED              = 7
    *       SEPARATOR_NOT_ALLOWED           = 8
    *       FILESIZE_NOT_ALLOWED            = 9
    *       HEADER_TOO_LONG                 = 10
    *       DP_ERROR_CREATE                 = 11
    *       DP_ERROR_SEND                   = 12
    *       DP_ERROR_WRITE                  = 13
    *       UNKNOWN_DP_ERROR                = 14
    *       ACCESS_DENIED                   = 15
    *       DP_OUT_OF_MEMORY                = 16
    *       DISK_FULL                       = 17
    *       DP_TIMEOUT                      = 18
    *       FILE_NOT_FOUND                  = 19
    *       DATAPROVIDER_EXCEPTION          = 20
    *       CONTROL_FLUSH_ERROR             = 21
    *       OTHERS                          = 22
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.
    When I run this program in foreground mode, the file gets saved(here in the above example I have just used my desktop path. but the actual requirement is to store file in shared-folder i-e Network Drive).
    But when i run the same program in background mode, No file is getting stored.
    Regards,

Maybe you are looking for

  • Set global variable in FOX formula

    Hi all, Does anybody know how to change the value of a global variable inside a FOX formula?. I can get its value and assign to a local variable but I would like to set the global value after reading a keyfigure and make some calculations. is it poss

  • Incorrect subpixel rendering iin FF 19.0.2

    In many situations FF does not correctly display subpixel rendering. It appears as if the color one one side of a leg is assigned also assigned to the adjacent pixel of the leg. For a font leg only one pixel wide, there is no black portion of the leg

  • Images do not show; help not successful

    Images do not load and the Help! suggestions do not solve the problem. I access the Netflix.com website and its .jpg images do not show. Right clicking on image location and selecting "Page Info" reveals that site is allowed to show image and "Media"

  • 'Unfortunately Walkman has stopped'

    walkman can't play on my experia z3 after phone updated, i didn't see unsinstall update on app, pls help me

  • CSS Tool Tips

    I'm hoping someone can point me in the right direction here. I have almost finished a site where on one page I have inserted some code from a tooltip I found on the net to create a rollover explanation of certain text. The problem is that now I have