Creating a File under a directory

hi
I want to create a File under a specific directory,say "mydirectory" using BufferedDataOutputStream.How can i do it?
thanks

BufferedDataOutputStream is not an existing class in the Java standard API. Did you mean BufferedOutputStream?
If you want to create a file under a specific directory, simply specify the complete path:
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("C:\\mydirectory\\data.bin"));

Similar Messages

  • 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 pdf files in UNIX directory from oracle reports

    I would like to know how to create pdf files in UNIX directory from oracle reports.
    Thanks,

    Please make your question more clear . Also mention the reports version.
    1) If you are runnning reports in Unix, you can give
    .... destype=file desformat=pdf desname=<filename>
    in command line
    Please refer docs below.
    2) If by your question you mean
    "My reports server is running in Windows but I want to ftp my files to Unix after creating it"
    then the answer is that you can use pluggable destination "ftp"
    .... destype=ftp desformat=pdf desname=<ftp url>
    Pluggable destinations download
    http://otn.oracle.com/products/reports/pluginxchange/index.html
    Thanks
    Ratheesh
    [    All Docs     ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf

  • Unable to create any files under '/' and /export/home as root user

    Dear Forum,
    Please help me on this problem.
    In my server I cant create any files under / and /export/home . But I can save files under /var, /tmp ,/opt
    #cd /
    #touch tempfile
    touch: tempfile cannot create
    #cd /export/
    # ls -lp
    total 2
    drwxr-xr-x   9 root     root         512 Oct 20 11:09 home/
    # cd home
    # touch testfile
    touch: testfile cannot create
    # id
    uid=0(root) gid=0(root)
    # df -kh
    Filesystem             size   used  avail capacity  Mounted on
    /dev/md/dsk/d0         9.9G   5.5G   4.2G    57%    /
    /devices                 0K     0K     0K     0%    /devices
    ctfs                     0K     0K     0K     0%    /system/contract
    proc                     0K     0K     0K     0%    /proc
    mnttab                   0K     0K     0K     0%    /etc/mnttab
    swap                    22G   1.2M    22G     1%    /etc/svc/volatile
    objfs                    0K     0K     0K     0%    /system/object
    /dev/md/dsk/d3         9.9G   6.8G   3.0G    70%    /usr
    /platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
                           9.9G   5.5G   4.2G    57%    /platform/sun4u-us3/lib/libc_psr.so.1
    /platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                           9.9G   5.5G   4.2G    57%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
    fd                       0K     0K     0K     0%    /dev/fd
    /dev/md/dsk/d5         7.9G   2.5G   5.3G    33%    /var
    swap                    22G   400K    22G     1%    /tmp
    swap                    22G    48K    22G     1%    /var/run
    /dev/md/dsk/d4          20G   4.7G    15G    25%    /opt
    /dev/md/dsk/d6          63G    36G    26G    58%    /data
    # more /etc/vfstab
    #device         device          mount           FS      fsck    mount   mount
    #to mount       to fsck         point           type    pass    at boot options
    fd      -       /dev/fd fd      -       no      -
    /proc   -       /proc   proc    -       no      -
    /dev/md/dsk/d1  -       -       swap    -       no      -
    /dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
    /dev/md/dsk/d3  /dev/md/rdsk/d3 /usr    ufs     1       no      -
    /dev/md/dsk/d5  /dev/md/rdsk/d5 /var    ufs     1       no      -
    /dev/md/dsk/d6  /dev/md/rdsk/d6 /data   ufs     2       yes     -
    /dev/md/dsk/d4  /dev/md/rdsk/d4 /opt    ufs     2       yes     -
    #10.183.103.11:/backup  -       /backup nfs     -       yes     rw
    /devices        -       /devices        devfs   -       no      -
    ctfs    -       /system/contract        ctfs    -       no      -
    objfs   -       /system/object  objfs   -       no      -
    swap    -       /tmp    tmpfs   -       yes     -
    10.183.103.11:/nfs_backup/NCMDB1 - /rman_backup nfs 0 yes rw,bg,intr,hard,timeo=600,wsize=32768,rsize=32768
    Regards,

    Please have the output of /etc/mnttab
    /dev/md/dsk/d0  / ufs rw,intr,largefiles,logging,xattr,onerror=panic,dev=1540000 1382602314
    /devices /devices        devfs dev=5400000     1382602306
    ctfs /system/contract ctfs    dev=5440001     1382602306
    proc    /proc proc    dev=5480000     1382602306
    mnttab  /etc/mnttab mntfs   dev=54c0001     1382602306
    swap /etc/svc/volatile       tmpfs xattr,dev=5500001       1382602306
    objfs   /system/object  objfs dev=5540001     1382602306
    /dev/md/dsk/d3  /usr ufs rw,intr,largefiles,logging,xattr,onerror=panic,dev=1540003 1382602315
    /platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1 /platform/sun4u-us3/lib/libc_psr.so.1   lofs dev=1540000     1382602313
    /platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1 /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1 lofs    dev=1540000     1382602313
    fd      /dev/fd fd      rw,dev=5700001  1382602315
    /dev/md/dsk/d5  /var ufs rw,intr,largefiles,logging,xattr,onerror=panic,dev=1540005 1382602315
    swap    /tmp tmpfs   xattr,dev=5500002 1382602315
    swap /var/run        tmpfs xattr,dev=5500003       1382602315
    /dev/md/dsk/d4  /opt ufs rw,intr,largefiles,logging,xattr,onerror=panic,dev=1540004 1382602318
    /dev/md/dsk/d6  /data ufs rw,intr,largefiles,logging,xattr,onerror=panic,dev=1540006 1382602318
    -hosts  /net    autofs nosuid,indirect,ignore,nobrowse,dev=57c0001     1382602321
    auto_home /home   autofs  indirect,ignore,nobrowse,dev=57c0002 1382602321
    NCM1:vold(pid393) /vol    nfs ignore,noquota,dev=5780001      1382602322

  • How to create a file under web application root from java program

    how to create a file under web application root from java program like an action class?

    like an action class?Huh? What exactly is your requirement?
    Creating a file is usually done with java.io API. Read the java.io tutorials how to play with files.

  • How to completely uninstall air app(clear up user files under app directory)?

    In the adobe air 1.1 install/uninstall document, it says "Removing an AIR application removes all files in the application directory. However, it does not remove files that the application may have written to outside of the application directory. "
    But it's not true. I found you cannot completely uninstall the app if there is any user files under app directory. If the user re-install the app, it will reminder the user "some error has occurred ...because an application with that name already exists at the selected installation location.... ".
    How to get rid of this problem if the user didn't clear up the folder manually before re-install?  If it's a limitation of adobe air, anyone could give me any evidence from official documents? Cause I have to persuade the user to accept it    Thank you.

    Psythik wrote:After returning my 6GB Zen Micro to the store (due to the fact that I filled it up quicked than I would've liked), I decided to go with the Zen Sleek player instead. Problem is, my computer still has the Zen Micro's drivers installed and apparantly it's conflicting with my Sleek because my computer won't recgonize it as a Zen Sleek even after installing the drivers (it just recgonizes it as a generic mp3 player). I can still transfer files to it as a would with a generic mp3 device in My Computer. Problem is, ID3 tags aren't properly sent this way (which is annoying when I want an album organized by track number).
    You shouldn't need to uninstall the Micro, it won't conflict. If tags aren't being sent properly then there might be some issue with the tags being read from the files. Check with a dedicated tagging program, and rewrite the tags perhaps on some test files.
    I'm assuming it's a Sleek with v2.xx firmware?

  • Why can't create file under /home directory?

    I user solaris10, and login as root,I find I can't create any file or directory under /home directory! It say "operation not applicable" ,Why? I am puzzled it for a long time. Anyone could tell how to do it?
    Thanks

    For Solaris,
    /home is not an on-disk file system, it is a file system under the
    control of the automounter, and only the automounter can create
    directories/files in it.
    If you don't want the automounter to manage /home, then remove the
    "/home" entry from /etc/auto_master
    (and issue the command "automount -v" to force the file
    to be reread, or reboot).
    However, the typical setup for Solaris is to locate user's home directories
    in /export/home.
    Kapil Khanna

  • Use of inlineframe to show a file under a directory in current WLS

    Hi,
    JDeveloper: 11.1.1.5.0
    WLS: 10.3
    My application creates PDFs in runtime under some directory of my "Managed Server" where the application runs. I need to show the generated pdf file in my application page.
    I am storing the location of the generated pdf in my pageFlowScope variable. In subsequent pages, I am trying to show the generated pdf thru inlineframe as:
    <af:inlineFrame id="if1"
    source="#{pageFlowScope.ContractLocation}"/>
    I am not able to see the pdf file getting displayed in my page. I am building the file path as below:
    System.getProperty("user.dir") + File.separator + "out" + File.separator + "Contract_1.pdf";
    Please suggest if my approach to show a file using af:inlineFrame is proper? And how to display the file which is somewhere under the current server running the application.
    Thanks
    Rathnam

    If your app knows the position of the file you just need to change the doGet method in the servlet. In this method you pass the path to the file, open a stream to the file and copy the file stream to the response stream. In this case you don't need the application module, as the parameter give you all needed information. In the end you should have something like
                // get path to file
                String filePath = request.getParameter("filepath");
                // Set the content-type. Only images are taken into account
                response.setContentType(mimeType + "; charset=utf8");
                File f= new File (filepath);
                FileInputStream lFileInputStream = FileUtils.openInputStream(f);
                ServletOutputStream lOutputStream = response.getOutputStream();
                IOUtils.copy(lFileInputStream, lOutputStream);
                lFileInputStream.close();
                lOutputStream.flush();Timo

  • Can not create a file under \window\system32 folder

    How do I create a folder in \windows\system32 in x64 machine through java code?
    Creating a file/folder under \windows\system32 fails and java creates a folder in \windows\syswow64 folder.
    pls see the code attached for example.
    My client wants to create a folder using my application.
    I dont want to use any native code suggested by microsoft. You can see in the following link
    http://msdn2.microsoft.com/en-us/library/aa365743(VS.85).aspx
    import java.io.*;
    public class FileTest{
         FileTest(){
              boolean created = writeFile();
              if (created)
                   System.out.println("File Created Successfully");
              else
                   System.out.println("Could not able to create the file");
         public static void main (String args[]){
              FileTest ft = new FileTest();
         public boolean writeFile(){
              try{
              Writer output = null;
              String text = "Sample Test File";
              if(!(new File("c:\\windows\\system32\\customFIle").exists())){
                   new File("c:\\windows\\system32\\customFIle").mkdirs();
              File file = new File("c:\\windows\\system32\\customFIle\\write.txt");
              output = new BufferedWriter(new FileWriter(file));
              output.write(text);
              output.close();
              return true;
              }catch(IOException ioex){
                   System.out.println(ioex);
              return false;
    Thanks in advance

    java_mani wrote:
    How do I create a folder in \windows\system32 in x64 machine through java code?Can the user that executes this Java code create "manually" a folder in that directory?
    Creating a file/folder under \windows\system32 fails and java creates a folder in \windows\syswow64 folder.
    pls see the code attached for example.
    My client wants to create a folder using my application.
    I dont want to use any native code suggested by microsoft. You can see in the following link
    http://msdn2.microsoft.com/en-us/library/aa365743(VS.85).aspx
    Why not?

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

  • 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

  • ITunes creating duplicate files under a hidden folder named "Volumes".

    It seems my iTunes program is secretly making a duplicate file in a hidden folder called "Volumes" on my laptop hard drive. It's now maxxed out my drive and I need to both remove the "Volumes" folder and make sure it doesn't get created and happen again.
    Details:
    Using a Powerbook G4 with an 80gb drive. Using iTunes 8. The iTunes library program is in the usual place on the lap top hard drive but the music library folder, where all the files get saved to, is on an external drive labeled "Media".
    Clicking normally and searching around my laptop hard drive, I do not see or am able to access the folder named "Volumes". But I know it exists as I ran a scan program called jdiscreport and it clearly shows a huge folder, 45gb, named "Volumes". There are also a few old flacs in the "Volume folder also. The iTunes duplicate files are in identically named folders as the external drive: iTunes Music located within Media, located within Volumes.
    When I rip a CD in iTunes (or the iTunes-LAME program I sometimes use), the files do go to the proper external folder as expected and as I've set in the iTunes preferences section. So why is iTunes also saving the same thing to this mystery "Volumes" folder on the lap top hard drive? How do I get rid of this folder without wiping my drive? How do I stop it from continuing?
    Help, I have 2gb of free space left!
    Thanks, James

    Hi I am having a similar issue, It all started when I tried to restore from the Time Machine and it threw a error back stating that there is no disk available. I was wondering how come and went to find out what is happening and was shocked to find out that actually my entire Macintosh HD has a duplicate copy inside the /Volumes folder. I went to the XTERM to investigate and found that the / (root) has a Users folder where all my stuffs like pictures, music, movies, documents reside and the same data or content is duplicated in the /Volumes/Macintosh HD/Users folder
    I first thought that it was only a link, but I later found that it is not a link and it is indeed a physical copy of all my User folders inside the /Volumes/Macintosh HD/Users folder and actually occupying my Hard disk space.
    I am not sure how this happened or how it is duplicating itself. I am also afraid to delete the stuffs inside the /Volumes folder as it might crash my system (it is already hidden - I assume it is hidden for some purpose). Please suggest any options, how I can get rid of these duplicated data and how to avoid such duplication in the future.
    Thanks
    Regards
    Chelvam.S.T

  • 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

  • Create Zip File In Windows and Extract Zip File In Linux

    I had created a zip file (together with directory) under Windows as follow (Code are picked from [http://www.exampledepot.com/egs/java.util.zip/CreateZip.html|http://www.exampledepot.com/egs/java.util.zip/CreateZip.html] ) :
    package sandbox;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    * @author yan-cheng.cheok
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // These are the files to include in the ZIP file
            String[] filenames = new String[]{"MyDirectory" + File.separator + "MyFile.txt"};
            // Create a buffer for reading the files
            byte[] buf = new byte[1024];
            try {
                // Create the ZIP file
                String outFilename = "outfile.zip";
                ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
                // Compress the files
                for (int i=0; i<filenames.length; i++) {
                    FileInputStream in = new FileInputStream(filenames);
    // Add ZIP entry to output stream.
    out.putNextEntry(new ZipEntry(filenames[i]));
    // Transfer bytes from the file to the ZIP file
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    // Complete the entry
    out.closeEntry();
    in.close();
    // Complete the ZIP file
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    The newly created zip file can be extracted without problem under Windows, by using  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html]
    However, I realize if I extract the newly created zip file under Linux, using modified version of  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html] . The original version doesn't check for directory using zipEntry.isDirectory()).public static boolean extractZipFile(File zipFilePath, boolean overwrite) {
    InputStream inputStream = null;
    ZipInputStream zipInputStream = null;
    boolean status = true;
    try {
    inputStream = new FileInputStream(zipFilePath);
    zipInputStream = new ZipInputStream(inputStream);
    final byte[] data = new byte[1024];
    while (true) {
    ZipEntry zipEntry = null;
    FileOutputStream outputStream = null;
    try {
    zipEntry = zipInputStream.getNextEntry();
    if (zipEntry == null) break;
    final String destination = Utils.getUserDataDirectory() + zipEntry.getName();
    if (overwrite == false) {
    if (Utils.isFileOrDirectoryExist(destination)) continue;
    if (zipEntry.isDirectory())
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(destination);
    else
    final File file = new File(destination);
    // Ensure directory is there before we write the file.
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(file.getParentFile());
    int size = zipInputStream.read(data);
    if (size > 0) {
    outputStream = new FileOutputStream(destination);
    do {
    outputStream.write(data, 0, size);
    size = zipInputStream.read(data);
    } while(size >= 0);
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    break;
    finally {
    if (outputStream != null) {
    try {
    outputStream.close();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    if (zipInputStream != null) {
    try {
    zipInputStream.closeEntry();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    } // while(true)
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    finally {
    if (zipInputStream != null) {
    try {
    zipInputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    if (inputStream != null) {
    try {
    inputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    return status;
    *"MyDirectory\MyFile.txt" instead of MyFile.txt being placed under folder MyDirectory.*
    I try to solve the problem by changing the zip file creation code to
    +String[] filenames = new String[]{"MyDirectory" + "/" + "MyFile.txt"};+
    But, is this an eligible solution, by hard-coded the seperator? Will it work under Mac OS? (I do not have a Mac to try out)
    p/s To be honest, I do a cross post at  [http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux|http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux] Just want to get more opinion on this.
    Edited by: yccheok on Apr 26, 2010 11:41 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Your solution lies in the File.separator constant; this constant will contain the path separator that is used by the operating system. No need to hardcode one, Java already has it.
    edit: when it comes to paths by the way, I have the bad habit of always using the front slash ( / ). This will also work under Windows and has the added benefit of not needing to be escaped.

Maybe you are looking for