Saving File - zip problem?

If i use this set of coding, i can receive the file and the bytes and save it to the current directory, with the zip file, it just creates the file without saving the bytes, anyone knows what is wrong? Is there another way to go abt saving file objects to the current directory which includes all types of files?
File file = new File("folder/Access.java");
          boolean flag = file.exists();
          System.out.println(flag);
          try
                                   FileOutputStream fos = new FileOutputStream(file.getName());
               FileInputStream is = new FileInputStream(file);
               long length = file.length();
               if (length > Integer.MAX_VALUE) {
            // File is too large
        byte[] bytes = new byte[(int)length];
              int offset = 0;
        int numRead = 0;
        while (offset < bytes.length
               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        if (offset < bytes.length) {
            throw new IOException("Could not completely read file "+file.getName());
        is.close();
        //return bytes;
        fos.write(bytes);
          }catch(IOException e)
               e.printStackTrace();
          }Most code sample comes from javaalmanac.com.

FileOutputStream fos = new FileOutputStream(file.getName());This gets an output stream to a file named Access.java in the current directory. However your first line of code suggests you might have expected to write to Access.java in the current directory's subdirectory named folder. If that is actually what you want, then try this instead:FileOutputStream fos = new FileOutputStream(file);PC&#178;

Similar Messages

  • Saving Files - A problem

    When I go to save a pdf file, instead of getting a small window the window fills my screen.  I've tried to minimize it, I've tried to "grab" the corner and drag it smaller.  What did I do that makes it so I can no longer see the file when I'm trying to save it?

    Saving files to SharePoint Document Library.
    For a test try this:
    Word 2010
    Disable all options in "Protected View"
    (-> Word Backstage -> Options -> Trust Center -> Protected View)
    Now you can create a new document in your document library. The
    save dialog comes up with the correct sharepoint path.
    Hope this helps
    DJWGermany

  • Hi, I cant open a document I have been working on. It has previously been saved without a problem now all I get is a box stating that the file cannot be opened. Any suggestions please?

    Hi, I reecntly purchased a Mac and the Pages App. But now I find that I cant open a document I have been working on. It has previously been saved without a problem now all I get is a box stating that the file cannot be opened. It is visible in both the Pages Windows and under Recent Items but just will not open. Any suggestions please?

    Hi Colourdoodles,
    Maybe the document is corrupted. Can you open other Pages documents? Preview may open it. Right click (or control click) on the document in Finder and Open With > Preview.
    If that works, Edit > Select All, Edit > Copy. Then paste into a blank Pages document. Formatting may be messed up, but you will have editable text. Then Save (with a different name), close and see if you can open the new document.
    Regards,
    Ian

  • Problem Saving Files CS5

    After years of no problems I am suddenly having a problem saving files.  This started with CS4 a few months ago, and has continued with CS5.
    When I attempt to Save As... I get an error message:
         Could not save as "{location & filename}" because the file is already in use or was left open by another application.
    The only place the file could be considered "in use" or "left open" would be due to Bridge.
    I get this error message whether saving as jpg, psd or any other file type.  If I retry saving the file then it will usually save properly after several attempts.  But if I close Bridge then it will save the first time every time.  I get the same error whether saving as the original file name or with a new name.
    I have been using Bridge to preview and select the images I want to edit for a very long time.  But this problem didn't start showing up until a short time ago, so I wonder about a problem introduced with an update??    Those who use Bridge know that it remains running in the background while the image is processed through Camera RAW and PS.  There has never been a reason to close Bridge when working in PS and it is not very convenient to do so just to save a file.
    If anyone has a solution to this I would like to hear about it.
    Thanks,

    Hi Jimcarke,
    My problem is very similar. Just Upgraded to CS5 from CS4.
    Graphic files, no problem.  I can save 80Mb and 30 layered mixed graphic files, even after editing.
    No JPEG's in the stack though. Perhaps I'll have a look at that!
    With simple JPEG's at 1.9mb, after editing, then as soon as I enter 'Save As,' Bingo the great blank screen'
    Problem seems worse if I get as far as rotating the image, then everything disappears instantly.
    Customer services have suggested all the usual remedies and now I can't open a file or edit anything
    I'm back to the insufficient RAM issue.
    I've just 'given up' and back to CS4 again and will try to get some work done for the morning.
    All good fun and an interesting way to spend a very sunny Sunday afternoon. (GB)
    Regards
    John

  • Problem saving files to PDF in Illustrator CS4 [Mac]

    Hi all,
    I'm having a problem with saving files as PDF's in illustrator CS4 - something I've happily done for years until about a week ago.
    It seems to be something to do with the "Save As" command. When I select Save As and then select PDF, the PDF saves as a copy of the current file rather than it saving as a file itself. It also doesn't rename itself properly. Saving a file in the .ai format seems unaffected.
    The multiple page function also seems to be affected - I can create multiple pages no problem, but upon saving the PDF reads as a single page PDF in both Acrobat and Preview. Reopening the same file in Illustrator reveals that the extra pages are there, but not showing in the PDF.
    Any thoughts? I've trashed preferences and repaired permissions, but no joy....
    Any help greatly appreciated

    Have you entered specific artboards in "use artboards"?

  • Are there any problems saving files in Pages for iPad?

    I have a new iPad, and I need to chose a wordprocessing App. Friends have advised me that there may be a difficulty saving files from Pages. If so then is there a recommendation for a different wordprocessing App ?

    I use Pages every day on my iPad. I have had great success with it.
    I use it with iCloud, and I use it on my Mac. I have created documents on the Mac, saved them to iCloud, opened them on the iPad, edited them there, saved that back to iCloud, opened them in the IOS Beta in iCloud.com, downloaded them to my Mac at work, and so on and so on...
    I have used Pages every way that you can possibly use it with iCloud, iCloud.com, and locally on my Macs. No problems whatsoever.
    Pages documents are saved automatically on the iPad as are all documents in all apps - at least as afar as I know. You do not have to actually save them on your own... no Save As... no Save commands at all in tha app. They are saved automatically with the last set of edits that you make in place.

  • Having problems getting saved files in PS CS3 to show up in folders in Vista - help?

    My sincerest apologies if this has floated across oyur screens before, but I don't seem to be pluggin in the correct set of keywrds to bring it up in the search if it has.
    Here's my dilemma. I just bought a new computer which came preloaded with Vista, and uploaded my old copy of CS3 onto it. The program seems to be working fine, except that when I open a file in Photoshop and edit it, then save it in a new file (as I do for most of my photoshoots, etc), or even when I save it in the orignial folder, the new "saved" file will not show up in the Vista folder. If I go back to Photoshop and open the folder via File>Open, I can access all of my pictures, but to I cannot access them to upload to the internet, email, use in other programs, etc.
    If I go into "Recently Changed Documents" I can find them, but they seem to be in a temp folder in the Adobe folders. But again, if I go back to Adobe, it says they are in the folder I put them in.
    Any ideas what's going on here?
    Thanks so much for any help you can offer,
    Cass

    They are hidden for whatever reason, either you have a permission problem or they are registered incorrectly with Explorer. Open the folder, then check Extras --> Folder Options. Disable the Hide System Files option and then the more generic Hidden Files section a little lower. If that reveals the files, it's time to check the File Types tab in the same panel and see, why it actually thinks your documents are system files. the simplest solution would be to remove the PSD association and then create it new, when you open a file wit6h a double-click. Of course al lthe above assumes that not some security tool or another application is "stealing" your file type associations. If you have such tools, checking their config may already solve the problems.
    Mylenium

  • Problem occurring when opening and saving files in AI SC5 with Windows 7

    Hi, I ‘am a Graphic Designer and first time working in UAE Windows 7 is basically the only OS here. My PC is:
    HP Elite 7000
    Intel® Core™ i5 CPU 2.67GHz
    4GB RAM
    32-bit
    Now to the problem, not that knowledgeable in IT stuff so here goes:
    1. Problem occurring when opening and saving files in AI SC5 with Windows 7. (You will actually see a “Not Responding” word coming out while opening and saving files, whether small or large files)
    2. Locked layers occasionally are moved accidentally.(Working on multiple layers is normal so we need to lock it specially the once on top. But there are times I still manage to select locked layers)
    3. After typing and locking the text, pressing “V” for the arrow key shortcut is still added to the text that is locked. (After typing I lock the text layer with my mouse and Press “V” to activate the arrow key… yes the arrow key is activated but the text is still typing the actual keyboard pressed)
    I’ve only use the brand new PC and installer for a month now. Not sure if this is compatibility issues or something else I’m not aware of.
    Thanks in advance to people that will reply.
    Cheers!!!

    Well I’m still wondering if it is compatibility issues because I’m also having problem with Photoshop CS5. These 3 are all bought at the same time (PC, Illustrator and Photoshop installers). The problem I’m having in Photoshop is not that too important, every time I Ctrl+O to view files, all PSD are shown in white paper like icons, no preview, and saving as well.
    Or I just purchased a corrupted or pirated installers… Adobe updates are done every time I’m prompted.

  • Problem with parameters to fix opening of old tabs and saving files when a new session is open

    Hello,
    Since 2 weeks I have a problem: I always fix my parameters to restore previous session with all my tabs and I choose that Firefox asks me where I want to save my downloaded files. Now each time I close Firefox and I reopen it, it is not taken into account, and 3 tabs are opened: Firefox, Google and Thank to install Zotero! I rechange it, but every time it opens these tabs and not my old tabs. The same for saving files. It goes back automatically to open start page and to save my file in Downloads. Even if I rechange, it comes back the same.
    I desinstalled CCleaner (I thought it could be that) but nothing changes!
    Please help. Thank you very much!
    Martha

    Here's what I would try:
    *Reset Firefox - this should fix the issue but it will change settings like where files are downloaded and what tabs open at startup back to their defaults.
    *Then change your download and session restore preferences back to how you like them.
    Here's how:
    #Go to Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    #Open the options window - Tools > Options > General
    #In the General panel set Firefox to open your tabs from last time and set Firefox to ask you where to save downloads.
    #Click OK
    That should do it. Let me know if this worked.
    Thanks,<br>
    Michael

  • Having problems saving files in CS2

    I'm learning the program: Classroom in a book from InDesign CS2. In the beginning when the file was small I was having no problem saving the doc. But after The doc got bigger and I had done many things to it, I would save the doc, the save word in file was gray as it is suppose to be, then I would close the file. When I reopened the doc all my work would be gone. I have recreated this 3 times now and the same thing keeps happening, NO SAVED FILE. What am I doing wrong??? Thank you advance for your help, Sherrine

    How are you opening the file (double-clicking an icon, File > Open,
    File > Open Recent, etc.)? Are you saving/opening over a network? It
    sounds to me like you may be opening the wrong file. Try doing some work
    on the file, and then Save As to a unique name. Then use File > Open
    Recent to open the file and see if your changes are there.
    Kenneth Benson
    Pegasus Type, Inc.
    www.pegtype.com

  • Saved File Groups Issue in Bridge Center - script problem?

    Hi all,
    I tried posting this in the Bridge forum with no replies. After browsing through this forum I'm wondering if this is a script problem?
    I have the CS2 premium, and use all packages. The problem I have is saving and retrieving files in the 'Saved File Groups' of Bridge Center. I can save Photoshop files no problem, but the idea is to be able to save other files from open applications in the group and then to recall them later. I can save Illustrator files with others in a group but only Photoshop files open, and it ignores the saved Illustrator files.
    With my InDesign files, it does not even recognise them as files to be saved. I can have a file open, click on "Save open files into a file group" and it will come up with a little box saying there are no open files to save!
    OS - XP sp2. Bridge 1.0.2
    If this can be helped with scripting, please explain clearly, I am a graphic designer and no very little indeed about scripting.
    Your help would be appreciated.
    Thanks,
    Thysje Arthur

    Hi,
    Do you mean that Windows displays “Network Shortcuts” folder when you click “Browse” icon? If so, please check if you configure the default local file location to the “Network Shortcuts” folder. You could refer to the image below to find the option of the default
    local file location.
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Help. Photoshop CC14 on Mac 5k (2014) running Yosemite 10.10.1. Photoshop stops responding when I'm opening files, saving files or creating new ones. Is anyone suffering the same problem? Does anyone have an answer?

    Help. Photoshop CC14 on Mac 5k (2014) running Yosemite 10.10.1. Photoshop stops responding when I'm opening files, saving files or creating new ones. Is anyone suffering the same problem? Does anyone have an answer?

    First, go install the MacOS 10.10 updates - you should be on 10.10.2.
    I haven't heard of Photoshop not responding during opens and saves.  Does it stop responding while the open/save dialogs are visible, or while Photoshop is actually reading or writing files?
    10.10.1 did fix a crash in the open/save dialogs, but 10.10.2 still has some odd issues (mostly program errors coming from the OS code) in the open/save dialogs.

  • Problem enlarging photo from saved file

    I saved my file to Maximum 12 on PSE7 and it won't let me print anything larger than an 11 x 13 photo.
    How should I save my file so that I can print as large as a 20 x 20.
    Help please!

    I saved my file to the largest setting on PSE7 (Maximum 12) and saved it to a disc, then took the disc  to Wolf Camera to print and the message I got when  trying to print was that the resolution was too low to print to a
    20" x 30" - it won't even print to an 8 x 10.
    I now know why the pros charge so much to print enlargements...
    Any help is greatly appreciated.
    Thank you!
    Date: Tue, 29 Jun 2010 13:16:05 -0600
    From: [email protected]
    To: [email protected]
    Subject: Problem enlarging photo from saved file
    What won't let you?
    >

  • Saving file format - suddenly having problems

    Hi all,
    I have been using PSE9 on my Intel iMac (OS 10.5.8) for a couple of weeks, and yesterday I started experiencing the following problems:
    (In Full Edit Mode)
    1) When trying the "Save As" command after working on an image, I was getting a message saying that my user account was not authorized to make changes, yet there is only one account on this computer.
    2) Shift-Command-S brings up the Save As window, but no matter what format I choose, it stays .jpg! I tried on a couple of different pictures, same results.
    Initially, I was able to save in PSD format when I moved the new file to a different location, i.e. instead of saving the new file in the original folder, I copied to desktop, but that's not working now.
    I opened PSE Preferences for Saving Files, and checked off append files with extensions "always" and "OK", but when I go back to the same Preference Panel, it has reverted to Never, which is the default position. I am wondering if this is the source of my problems.
    I have tried:
    placing the Preference files for PSD and Organizer in the trash and re-launching PSE9.
    Trashing Preference files, then restarting the computer and re-launching PSE9.
    Uninstalled PSE 6.
    Uninstalled PSE 9 and performed a reinstall off the CD. I was able to Save As a PSD file for a day, now back to the same situation, also still getting an error message if I try to save a JPG file in the folder of origin for that image.
    What should I do next?
    Martin

    I opened PSE Preferences for Saving Files, and checked off append files with extensions "always" and "OK", but when I go back to the same Preference Panel, it has reverted to Never, which is the default position. I am wondering if this is the source of my problems.
    Yes. It is a known bug. Your options are to trash the prefs again and never, never, never open the Saving Files preferences pane again (just going there causes this), or to add the file extension in manually when saving. (The default position is Always, but merely opening the saving files preference sets it to Never.)

  • Problems saving Files on Lion-Server

    My colleagues frequently report problems saving files stored on our Lion-Server machine. This usually applies to Photoshop CS6 documents but has been reported fpr MS Word .docx-Files as well. Usually the problem can be circumvented by savin the files in question  on the local machine and later copy them back to the server.
    Unfortunately the errors happen at random times where I usually have no access to either the cient computer or the server so I have no clue of wht is going wrong.
    The Server-Logs, especially the AppleFileServer Logs don't show any information related to anx client side error message.
    The only thing I see are entries in /var/log/system.log reading something like
    "Jul  9 15:36:14 servername AppleFileServer[1368]: MDSChannelPeerCreate: (os/kern) invalid argument"
    I'm not sure, if these messages are related to the failure of saving files, but they are the only clue I have so far.
    Has anyone experienced similar problems or better has a solution to avoid thes errors entirely?

    My colleagues frequently report problems saving files stored on our Lion-Server machine. This usually applies to Photoshop CS6 documents but has been reported fpr MS Word .docx-Files as well. Usually the problem can be circumvented by savin the files in question  on the local machine and later copy them back to the server.
    Unfortunately the errors happen at random times where I usually have no access to either the cient computer or the server so I have no clue of wht is going wrong.
    The Server-Logs, especially the AppleFileServer Logs don't show any information related to anx client side error message.
    The only thing I see are entries in /var/log/system.log reading something like
    "Jul  9 15:36:14 servername AppleFileServer[1368]: MDSChannelPeerCreate: (os/kern) invalid argument"
    I'm not sure, if these messages are related to the failure of saving files, but they are the only clue I have so far.
    Has anyone experienced similar problems or better has a solution to avoid thes errors entirely?

Maybe you are looking for