Creating directory when creating a File?

In this code example, I was unable to create that file if the directories 'someDirectory1'
and 'someDirectory2' doesnt exist.
Does somebody know what I have to do to avoid the FileNotFoundException in the constructor of the
FileWriter??
String filePath = volume + "\\" + someDirectory1 + "\\" + someDirectory2 + "\\" + fileName;
FileWriter outF = new FileWriter(filePath);
outF.write(someString);
outF.close();thanks!

Thank you very much, it works!
<pre>
String filePath = volume + "\\" + someDirectory1 + "\\" + someDirectory2 + "\\";
File dirs = new File(filePath);
dirs.mkdirs();
FileWriter outF = new FileWriter(filePath + fileName);
outF.write(someString);
outF.close();</pre>

Similar Messages

  • Wrong classes output directory when use of dependant projects

    Hi,
    JDev 10.1.2.1 but also in previous versions.
    Windows XP Prof, AMD Athlon, 1 Go Mem
    I have following setup:
    Projects:
    DTO (data transfer objects and utility classes used in other projects)
    -> dependies: none
    Directory tree:
    MyWorkspace\DTO\classes
    MyWorkspace\DTO\src
    Model (model classes)
    -> dependies: DTO
    Directory tree:
    MyWorkspace\Model\classes
    MyWorkspace\Model\src
    View (JClient app)
    -> dependies: DTO, Model
    Directory tree:
    MyWorkspace\View\classes
    MyWorkspace\View\src
    WebView (Struts app)
    -> dependies: DTO, Model
    Directory tree:
    MyWorkspace\WebView\deploy
    MyWorkspace\WebView\model
    MyWorkspace\WebView\public_html
    For some unexplained reasons sometimes (difficult to reproduce)
    JDev get confused and DTO classes, sometimes Model classes are copied to the View project classes directory.
    Example utility class of the DTO project:
    source:
    MyWorkspace\DTO\src\com\photoswing\dto\util\TextUtils.java
    instead of being generated in:
    MyWorkspace\DTO\classes\com\photoswing\dto\util\TextUtils.class
    is found in the View claases output directory (directory tree created by JDev):
    MyWorkspace\View\classes\com\photoswing\dto\util\TextUtils.class
    I noticed that regularly the JDev navigator has synchronization problems and can't find the class when activating the right-click Select in Navigator action in an open source file.
    This generally happens when switching from source files of different projects.
    Now if you compile a source file and the navigator has a synchronization problem following warning is displayed:
    Warning: The file is not part of the active project DTO.jpr, compiled class will be written to DTO.jpr output directory
    When only one file gets compiled this can be repaired easely by deleting the class written in the wrong directory.
    But when several files are changed and are compiled the warning is only displayed for the current source file and all classes output trees must be scanned manually.
    When testing the app if I'm not wrong JDev reads from the classes directories and doesn't produce a jar file, so deleting manually the wrong classes is a valid workaround.
    But what if the app gets deployed and jars are generated?
    I can't imagine myself changing manually the produced jars by removing the wrong classes and what about the manifest?
    Your help is requested.
    Regards
    Fred
    PS Can't provide a TestCase => happens in complex environment only.

    Glad to know I'm not the only one having that serious problem.
    JDev by default create at least 2 different projects (model and view) so it seems to be a standard.
    Working simultaneously on source files of different projects seems to the cause the trouble.
    Is there somekind of patch available?
    Could somebody of Oracle answer the question of the first message of this thread?
    Thanks
    Fred

  • Creating a file in different directory.....

    i have program that uses File class from Java IO package for creating a text file. I have written this program in c:\test\proj and i am running the program in that location. So obviously text file is created in the same directory...
    But the information from this text file is required for my servlet that runs on web server tomcat 4.1..so i have to manually copy this file and place this on the required directory...i have written program to create the same file on in C:\Program Files\Apache Group\Tomcat 4.1\webapps\examples this directory but this is not happening..I reckon this is because of the spaces in the directory names....
    my problem is i am running program on c:\text\proj directory and i want text file to be created in C:\Program Files\Apache Group\Tomcat 4.1\webapps\examples...
    the statement i am using to create a file is...
    File f = new File("C:/Program Files/Apache Group/Tomcat 4.1/webapps/examples/ping.txt");
    do i have to modify the statment????
    please provide me with a solution...
    thanx

    You must be getting an IOException of some description when you open the output stream to the File.
    Or else you're looking for your file in the wrong place ...

  • Unable to Create a file in a directory through a Job

    Hi,
    We have a anonymous block which uses utl_file package
    It created a file in an oracle directory.
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
          DECLARE
       v_definition_clob    CLOB;
       v_codes              VARCHAR2 (32767);
       v_engine_name        application.NAME%TYPE      := 'CLAIMS';
       v_knwldgebase_name   knowledge_base.NAME%TYPE   := 'CLAIMS';
       v_rule_name          VARCHAR2 (32767);
       v_msg                VARCHAR2 (200);
       fid                  UTL_FILE.file_type;
    BEGIN
       fid :=
          UTL_FILE.fopen ('MID5010_DOC1TEMP', 'Diagnosis_Report.csv', 'W', 32767);
       UTL_FILE.put_line (fid, 'Rule Name ,Associated Codes');
       FOR rule_name IN (SELECT DISTINCT rh.NAME, rh.rule_header_id
                                    FROM rule_header rh,
                                         knowledge_base kb,
                                         application app
                                   WHERE
                                         app.application_id = kb.application_id
                                     AND rh.knowledge_id = kb.knowledge_base_id
                                     AND app.NAME = 'CLAIMS'
                                     AND kb.NAME = 'CLAIMS')
       LOOP
          v_codes := NULL;
          BEGIN
             SELECT definition
               INTO v_definition_clob
               FROM rule_header
              WHERE rule_header_id = rule_name.rule_header_id;
          EXCEPTION
             WHEN NO_DATA_FOUND
             THEN
                v_definition_clob := EMPTY_CLOB ();
             WHEN TOO_MANY_ROWS
             THEN
                v_definition_clob := EMPTY_CLOB ();
          END;
          DBMS_OUTPUT.ENABLE (50000000);
          FOR code_indx IN (SELECT   d.diagnosis_code AS code
                                FROM midev.diagnosis d
                               WHERE d.diag_ctgry_lkpcd = 'D' AND ROWNUM < 10
                            ORDER BY 1 ASC)
          LOOP
             IF REGEXP_INSTR (v_definition_clob, code_indx.code) > 0
             THEN
                v_codes := v_codes || code_indx.code || '|';
             END IF;
          END LOOP;
          IF LENGTH (v_codes) > 0
          THEN
             v_codes := CHR (39) || v_codes;
          END IF;
          UTL_FILE.put_line (fid,
                                REPLACE (rule_name.NAME, ',', ' ')
                             || ','
                             || SUBSTR (v_codes, 1, LENGTH (v_codes) - 1)
       END LOOP;
       UTL_FILE.fclose (fid);
    EXCEPTION
       WHEN OTHERS
       THEN
          UTL_FILE.fclose (fid);
          v_msg := DBMS_UTILITY.format_error_backtrace ();
          DBMS_OUTPUT.put_line (v_msg || SQLCODE || ',' || SQLERRM);
    END;
             Now when i converted anonymous block into a procedure "DIAGNOSIS_REPORT_PROCEDURE" and calling it thorough a job its not creating the file. we are using the below code to create a job
                    BEGIN
       --DBMS_SCHEDULER.drop_job (job_name => 'DIAGNOSIS_TESTING_REPORT_3');
       DBMS_SCHEDULER.create_job
          (job_name             => 'DIAGNOSIS_TESTING_REPORT_3',
           job_type             => 'STORED_PROCEDURE',
           job_action           => 'DIAGNOSIS_REPORT_PROCEDURE',
           start_date           => to_Date('30-Mar-2012 16:44:03','dd-mon-yyyy hh24:mi:ss'),
           --repeat_interval      => 'freq=yearly',
           enabled              => TRUE,
           comments             => 'DIAGNOSIS_TESTING_REPORT_3'
    END;Any help would be appreciated..
    Thanks
    P Prakash.

    I got the answer.
    If we need to run a procedure through job then we must execute privilege .

  • Installer does not create directories/files in APPDATA directory

    I have an installer that installs the application into the Program Files directory, and additionally, is supposed to create application files and a directory structure in the Public App Data (%APPDATA%) directory of the Windows installation. In the LV Build Specification, I have created the appropriate destinations, moved the project specific files to those destinations in the Source File section, and tried combinations of the source file properties. When I run the installer, the application installs into Program Files correctly, however, nothing is created in %APPDATA%. I have even marked these files as vital to the installation, in order to stop, if there's a problem. No problem was indicated during the installation.
    Thanks for the help.

    Hi Jlgeris,
    I build a little istaller and told the installer to put something in the appdata directory as you can see in the attached files. After  installing it, I found the file in the right directory.
    Did you do this in the same way?
    regards
    Tobias
    Attachments:
    Destinations.png ‏89 KB
    Source_Files.png ‏93 KB
    Appdata.png ‏95 KB

  • 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

  • I'm doing something wrong when I try to create a file.

    I'm working with binary files, trying to do a log file and I'm having this error
    java.io.FileNotFoundException: log.dat (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at Servidor.XServer.log(XServer.java:186)
         at Servidor.XServer$nwc$readLine.run(XServer.java:312)This is because the file is not being created, but I don't know why, here is my code, where I try to create it.
         /// ANADIR EVENTOS AL ARCHIVO LOG // ADD EVENTS TO LOG FILE
         int log(String arg[], String ip , String voto){
              File file = null;
             if (file == null) {
                 System.out.println ("Default: log.dat");       
                 file = new File ("log.dat");     //    why it isn't creating the file?
             // Now write the data to the file.
             try{
                  FileInputStream file_input = new FileInputStream (file);
                 DataInputStream data_in    = new DataInputStream (file_input);
                 String iptmp ="";  // ip tmp
                 String vot1=null;          // vot 1er lugar tmp
                 String vot2=null;        // vot 2do lugar
                 int itmp=0;          // intentos tmp
                 while(true){
                    try{
                      iptmp= data_in.readUTF();
                      vot1= data_in.readUTF();
                      vot2=data_in.readUTF();
                      itmp=data_in.readInt();
                 DataOutputStream data_out = new DataOutputStream (new FileOutputStream (file));
                 voto=(voto.substring(0, 1)+chart.get(Integer.parseInt(voto.substring(1, voto.length()))));
                           // SI EL IP YA VOTO POR EL PRIMER EQUIPO (ERROR EN VOTO)
                        if (iptmp.equalsIgnoreCase(ip) && vot1!=null && voto.startsWith("1")){
                             data_out.writeInt(itmp+1);
                             return(-1);
                        // SI EL IP YA VOTO POR EL SEGUNDO EQUIPO (ERROR EN VOTO)
                        if (iptmp.equalsIgnoreCase(ip) && vot2!=null && voto.startsWith("2")){
                             data_out.writeInt(itmp+1);
                             return(-1);
                        // SI UN IP NO HA VOTADO POR EL PRIMER LUGAR     
                      if (iptmp.equalsIgnoreCase(ip) && vot1==null && voto.startsWith("1")){
                         data_out.writeChars(ip);  // ip
                         data_out.writeChars(voto);   // voto por primer lugar
                         data_out.writeInt(itmp); // intentos de votos
                         // SI UN IP NO HA VOTADO POR EL SEGUNDO LUGAR
                      if(iptmp.equalsIgnoreCase(ip) && vot2==null && voto.startsWith("2")){     
                         data_out.writeChars(ip);  // ip
                         data_out.writeChars(voto);   // voto por segundo lugar
                         data_out.writeInt(itmp); // intentos de votos
                      data_out.close();
                 }catch (EOFException eof) {
                             System.out.println ("End of File");
                             break;
                      data_in.close();
             } catch (IOException e) {
                   e.printStackTrace();
              return 0;
         }Would you help me out with this? I don't see what is wrong I'm following an example from the oracle / java tutorial and I cant see what is different

    I´m not sure if Im understanding what you´re saying... If you dont describe the path, then the file will be created in the project folder, right?
    check this program out
    it doesnt specifies a path but if you try run it the file will be created in the project folder. ¨
    import java.io.*;
    import java.util.*;
    /**  Write a primitive type data array to a binary file.**/
    public class BinOutputFileApp
      public static void main (String arg[]) {
        Random ran = new Random ();
        // Create an integer array and a double array.
        int    [] i_data = new int[15];
        double [] d_data = new double[15];
        // and fill them
        for  (int i=0; i < i_data.length; i++) {
          i_data[i] = i;
          d_data[i] = ran.nextDouble () * 10.0;
        File file = null;
        // Get the output file name from the argument line.
        if (arg.length > 0) file = new File (arg[0]);
        // or use a default file name
        if (file == null) {
            System.out.println ("Default: numerical.dat");
            file = new File ("numerical.dat");
        // Now write the data array to the file.
        try {
          // Create an output stream to the file.
          FileOutputStream file_output = new FileOutputStream (file);
          // Wrap the FileOutputStream with a DataOutputStream
          DataOutputStream data_out = new DataOutputStream (file_output);
          // Write the data to the file in an integer/double pair
          for (int i=0; i < i_data.length; i++) {
              data_out.writeInt (i_data);
    data_out.writeDouble (d_data[i]);
    // Close file when finished with it..
    file_output.close ();
    catch (IOException e) {
    System.out.println ("IO exception = " + e );
    } // main
    } // class BinOutputFileApp

  • Cannot create a file when that file already exists, but should overwrite

    Hi,
    I need the same file name which is at Sender side and when it reaches to Receiver directory without timestamp.
    for eg., Sender side : Yeswanth.txt
    and also receiver side   :  Yeswanth.txt
    but, here it should overwrite the existing file (because, the sender side file name is always constant) at receiver directory when the job schedules for each time.
    Processing parameters i has given on Receiver side:
    File Construction Mode  :  Create
    put file  : Use Temporary File
    and I enabled the Adapter Specific Message Attributes at Sender side and Receiver side.
    Error getting receiver side at communication channel :
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException:
    Yeswanth.txt: Cannot create a file when that file already exists. : com.sap.aii.adapter.file.ftp.FTPEx: 550
    Yeswanth.txt: Cannot create a file when that file already exists.
    Reward points for useful answers.
    Regards,
    Yeswanth.
    Edited by: YeswanthRaj Kumar on May 23, 2008 8:20 AM

    Hi Yeswanth
    Then you can try with a "Add Counter". This will create new file each time with the same name but a counter will be added to the file name at the end specifying the number of times it is created.
    You can also the specify the format to create the counter once select this option u can correspondingly fill the Format and step fields.
    Will this be fine.
    Regards
    Ashmi

  • FTPEx: 550  : Cannot create a file when that file already exists.

    Hi experts,
    I am working on idoc to file scenario and PI 7.1. The idoc is split into 3 files.
    In sxmb_moni , the message is successful , but in rwb( Message montoring) i am geeting the fllowing  Error message.
    ' Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: An error occurred while connecting to the FTP server '172.19.125.190:21'. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 550 /Storedata/Outbound/0000001802: Cannot create a file when that file already exists. '. For details, contact your FTP server vendor..'
    and this error message is not displayed for all the target files , some files are getting created succesfully.
    After some times , the file in error status , gets created automatically.
    What may be the reason.?
    Thanks in advance .
    Best Regards,
    Anil

    There seem to be already some files in your Target Directory with the same name as your new files (which the CC is trying to place) and the CC is not able to overwrite the existing files and hence the error...check this.
    Check: http://help.sap.com/saphelp_nwpi71/helpdata/EN/44/69d7cfa4b633eae10000000a1553f6/content.htm
    14.      Select the File Construction Mode.
    u25CB       Create
    The file is created. The document received last is saved in each case.
    If you want the created file to be overwritten, select Overwrite Existing File. If you do not set the indicator, processing is stopped until the created file is processed.
    You can only set the indicator if you select Use Temporary File under Put File below.
    Regards,
    Abhishek.
    Edited by: abhishek salvi on Jul 28, 2009 6:59 PM

  • Does SAP create missing files TRACExx when starting up?

    Hi there,
    I'm working on a documentation regarding a system copy from a productive system to a consolidation system.
    We're using Sun Solaris 10/64Bit with Oracle 10g2 and Netweaver 7.00.
    In the directory /usr/sap/<SID>/DVEBMGS_xx/log there are several files SAP uses:
    - ALALERTS
    - ALMTTREE
    - ALPERFHI
    - ENQBCK
    - SLOGxx
    - TRACE
    - TRACE00...TRACE07
    My question concerns the TRACE-files. Only the file TRACE seems to be used by the consolidation system, but there are still eight files TRACE00 up to TRACE07 that were last accessed in 2008 and before.
    These files are filled with data from former consolidation systems that got overwritten everytime by the system copy. Now, after the new copy, the SAP system is still down. May I delete these files? Does SAP create these files new when starting up?
    Greetz, Uwe.

    Hi,
    Yes you can delete those files at any time. Check SAP Note 16513, it may help you.
    Thanks,
    Sushil

  • 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

  • The file path and directory about the .exe file created in LabView, who knows?

    I have a project, in the project, VIs and documents(.doc,.txt,.tdms,etc.) in different directories, and when the project run in the labView, it can find the directories and files, but when I created .exe file, I found the directories had changed and I didn't know the directory structure in the file, anyone know it?
    Thanks for any reply!
    YangAfreet

    Have a look at the link in my earlier post:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=267439#M267439
    LabVIEW Champion . Do more with less code and in less time .

  • CCME 7.1 - Local directory Parse Error[4] after created cnf-files

    Hi,
    When I have created the cnf files under telephony-services, I've got the following issue :
    -> when I try to check to complete local directory (press the submit button without filing any fields) the IP phone display Parse error [4]:
    Workarround:
    -> after a "no create cnf-files" and "create cnf-files" under telephony-services the problem is solved !
    If that can help you.
    Olivier

    Hi,
    Thanks, but I'm already in 12.4(24)T
    Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4(24)T, RELEASE SOFTWARE (fc1)
    The workaround continue to work for the moment ;)
    thanks
    Olivier

  • When saving a File OS Is Creating Multiple Folders With The Same File Name

    Not sure what I changed but, now when I save a any file (ppt. word, Keynote,Pages e.g.,) to the desktop or any other location the OS will also create multiple file folders with the same file name as the file I'm saving. Inside the folders are what appears to be files locating the saved files. What can I do to fix this problem?
    I'm using the 10.7.2 version
    MacBook Pro

    Misio wrote:
    It looks like a finder bug. To replicate, I surf to any website, I right-click on a jpg image, select "Save Image As" and in the window that pops up I type in the filename "000.jpg", I select the folder Pictures, and click on Save.
    BTW, I don't know why, but the file was saved only as "000" without the file extension ".jpg". Does anybody know why?
    the extension is simply hidden. go to the get info panel for the file and uncheck the option to hide the extension.
    Then I surf to another image, and again I save it as "000.jpg" and now it asks me if I want to replace the existing filename, although the existing one is "000" and I try to save as "000.jpg", so I say yes, and then magically the file is saved with the full filename including the extension "000.jpg"
    When I did it a couple of times, always saving image as "000.jpg" from various sources, I ended up with two distinct files named "000" and both in the same folder Pictures.
    Please advise.
    it sounds to me like you saved one file as 000.jpg and the other and 000.jpg.jpg.
    check the info panels for the files for full names to verify if this is the case.

  • I created a file in Photoshop CS5 (a photo) and another in Illustrator CS5 (a graph) to place in my InDesign CS5 brochure. When the Photoshop and Illustrator files are placed in InDesign, they look blurry - whether viewed in InDesign, printed, or saved as

    I created a file in Photoshop CS5 (a photo) and another in Illustrator CS5 (a graph) to place in my InDesign CS5 brochure. When the Photoshop and Illustrator files are placed in InDesign, they look blurry - whether viewed in InDesign, printed, or saved as a PDF. Can anyone give me some tips on how to fix this? Thanks!

    Ask in the program forums
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

Maybe you are looking for

  • Find the number of connections coming through a listener

    Hi, We have 10 listeners on our database. How to find out at runtime , how many users are accessing through a specific listener. Is v$dispatcher the view needed to query. Please guide. Thanks.

  • Page expire problem in one env of two environments having same code

    Hi, We have an web application deployed into two environments. The application versions and server versions are same in both environments. We are using sun one application server. When we click on back button (Say Env1) we are getting page exipre pro

  • Need help using method check_changed_data correctly

    I'm using method check_changed_data in my ALV program to update the grid with changes the user makes. The method works fine for this purpose. But I also want to know if any data actually changed. Can anyone give me an example? FORM update_vendor . do

  • Why won't the photo gallery on the iPhone stay in order?

    Hi! Question... I used to have the first iPhone, and when I'd upload my photo album thru iTunes, it would put all of the pictures in alphabetical order. I really liked that, because I could find pictures of all my friends and things by name super-qui

  • Need solution for Conflict in Multi-Replication

    Hey All I have multimaster replication between A location and B location and we Sync both at 5 O'Clock. I have Curoser in database trigger. For Example, Cursor ABC IS SELECT ITEM_QTY FROM LOCN_STK Where Item_code = NEW.ITEM_CODE; BEGIN OPEN ABC; FETC