Saving through save filechooser

Hi,
I'm having a very strange problem when I try to save a JTree to a file, whos name is specified by the user through a chooser.showSaveDialog. Basically I have a method to save the tree which i used before i introduced the filechooser. The saving was working perfectly without errors. Then as soon as I had the filechooser code, and i try and save, the program just crashes and although a file is created i don't think anything is being saved.
Could someone please help?!
Here is the code with filechooser:
JFileChooser chooser = new JFileChooser(".");
chooser.addChoosableFileFilter(new MyFilter());
int returnVal = chooser.showSaveDialog(this);
File file;
chooser.setDialogTitle("Save As File");
if (returnVal == JFileChooser.APPROVE_OPTION) {
     file = chooser.getSelectedFile();
     String f = file.getName();
     if (file.exists()) {
           returnVal =  JOptionPane.showConfirmDialog(this,
                          "Replace existing file?");
           if (returnVal != JOptionPane.YES_OPTION)
                          return;
     saveTheTree("f + .map");
}the saveTheTree method simply takes the filename to save the map as, and serializes my JTree object, i know this method works because if I try it on it's own the tree will be saved.
Thanks in advance!

I know it's quite late to reply this post. But this is for others from now....
Bellow code returns file name with extension e.g. test.map, abc.txt
String f = file.getName();I think you should not append file extension explicitly like:
saveTheTree(f + ".map");try this instead:
saveTheTree(f);Thanks,
typurohit

Similar Messages

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog}
    i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
    response.setHeader("Pragma", "public");
    response.setHeader("Cache-Control", "no-cache");
    *** download file
    if((trans !=null)&&(trans.equals("download")) )
    response.setContentType ("application/x-download");
    response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
    %>
    <script>
    window.location.href=<%=gallerypath+fileName%>';
    </script>
    <%
    trans="";
    //System.out.print("download : "+fileName );
    //***************************************

    Can you try below code, It should work...
    <%
    String myFileName = request.getParameter("fileName");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
    String root = "D:/";
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    try {
    in = new BufferedInputStream
    (new FileInputStream(root + myFileName));
    int ch;
    while ((ch = in.read()) != -1) {
    outs.print((char) ch);
    finally {
    if (in != null) in.close(); // very important
    outs.flush();
    outs.close();
    in.close();
    %>

  • Work I do on my iMac is not always compatible with my iPad when work is saved through iCloud.

    My work on Pages which I do on my iMac & iPad is saved through iCloud to each devise, it is not always compatible, especially word wrap and occasionally copy issues. Can someone explain if this is a weakness of the software. Or is there another explanation?

    Hello LenOwl,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iCloud: Troubleshooting Documents in the Cloud
    http://support.apple.com/kb/TS3991
    Best of luck,
    Mario

  • Unable to import TV programs saved through TV tuner

    I have an iTouch and some TV programs saved on my PC (saved through the TV tuner). They are in .dvr-ms format and I can't import them into iTunes. When I try to import one of the TV programs, nothing happens (no error message or anything). iTunes Help tells me how to convert a file once it has been imported into the iTunes Library, but it is absolutely useless in helping to get files such as these into the iTunes Library first. I bought this iTouch principally so that I could watch saved TV programs while I am on the road. I will be very unhappy if I'm not able to do that. Any help?

    blame the manufacturer of your tv card and Microsoft.
    The tv card I use included lovely software that gives me several options for export of recorded material-divx,mpeg 4, mpeg 2, h.264 for iPod and the iPod Touc/iphone, etc.
    Good luck finding software to convert whatever format the stuff you saved is in, I recommend doing a google search.
    PS- read this for info on file format and possible solutions to get it out of MS proprietary format into something usable: http://en.wikipedia.org/wiki/DVR-MS

  • When uploading images edited & saved through PS CS 5 to sites like Blogger they appear very grey?

    Images editied and saved through CS 5 are appearing VERY grey when uploaded to other sites like Blogger. I have never had this issue in my 3 years with the program and have tried everything to my knowledge. Please help!

    It's user error.
    Make sure your image has been converted to RGB with an sRGB profile before saving as a JPEG and uploading it to the server.
    Use Convert to Profile from the Edit Menu.  DO NOT use "assign profile".

  • Problem saving through JFileChooser

    Hi,
    I'm having a very strange problem when I try to save a JTree to a file, whos name is specified by the user through a "chooser.showSaveDialog". Basically I have a method to save the tree which i used before i introduced the filechooser. The saving was working perfectly without errors (I could load the tree back in perfect too). Then as soon as I added the filechooser code, and i try and save with the same save method, the program just crashes. The filechooser is doing something which I just can't understand.
    Could someone please help?!
    Here is the code with filechooser:
    JFileChooser chooser = new JFileChooser(".");
    chooser.addChoosableFileFilter(new MyFilter());
    int returnVal = chooser.showSaveDialog(this);
    File file;
    chooser.setDialogTitle("Save As File");
    if (returnVal == JFileChooser.APPROVE_OPTION) {
         file = chooser.getSelectedFile();
         String f = file.getName();
         if (file.exists()) {
              returnVal = JOptionPane.showConfirmDialog(this,
                             "Replace existing file?");
              if (returnVal != JOptionPane.YES_OPTION)
                             return;
         saveTheTree("f + .map");
    the saveTheTree method simply takes the filename to save the map as, and serializes my JTree object, i know this method works because if I try it on it's own, the tree will be saved.
    Thanks in advance!

    saveTheTree("f + .map");Sorry that's a typo, in my code it is correctly written as
    saveTheTree(f + ".map");

  • Illustrator CC 18.1.0 crashes when saving files (Save As)

    I recently purchased and installed Adobe Creative Cloud 2014. When using Illustrator 2014.1.0 (18.1.0), the app frequently crashes when I try to save a file (Save As... to another format such as SVG). It's not repeatable every time, but it happens fairly often enough to lose work. Occasionally, it will crash when attempting to open a file - the app freezes when I try to navigate to a folder in the Open File dialog box and then crashes. I have never seen it crash when launching the app, and I do not have any external tablets (such as Wacom) or any third-party plug-ins installed. I'm running Mac OS X 10.10 Yosemite with a 2009 13-inch MacBook Pro with 8 GB RAM and NVIDIA GeForce 9400M.
    I've searched through the Adobe forums and in other online resources and have only found threads about Illustrator crashing during startup or when having incompatible third-party plug-ins or certain Wacom tablets installed, of which I have neither.
    Anyone have any suggestions of a fix or workaround?
    Thanks in advance!

    Hi Macbook-adobe
    What happens when you try to open any file from the same location where you are saving the file using Save As command ?
    Will it be possible to join a connect session with me ?
    Please do let me know about your time availability ?
    Thanks & Regards,
    Raghuveer Singh
    [email protected]
    Time Zone: +5:30 GMT (IST)

  • Creation of delivery when sales order is saved through VA01

    Hi All
    We got the requirement in such a way that
    we are creating sales order of type (ZOR -standard order ) . Configrration is donde in such a way that when the order is saved one dilvery will be created for that order of deilvery type ZLF .as this is assginned as default delivery type in VOV8 .
    Hre we have two delivery types ZLF and  ZF and we have diffrent different item categories for that sales order like ZZTC , ZPU ,
    and ZTDP .
    our requirement is  as follows
    case1:
    when we create sales order through va01 (order type - ZOR standard order ) having onlu one item category ZPU  then delivery should be created of type ZLF it is happing correctly .
    case 2:
    when we create a sales order through va01 having  non ZPU item categroies like ZZTC and ZTDP dlivey should not be created  for that sales oder on saving that order .one success message is thwoing as salers order has been created but delivry cannot be created for this order .this is  is also happeing correctly . for this we have copied a rottine no 102 from VOFM  and we have added some logic
    but the problem is
    when we create a sales order having diffrene item categories ( one condiotn here one item should be ZPU) and other item is  ZZTC while saving the sales order delivery is getting created partially for one item only not for two items i mean delivery is getting created only for item categroy zpu the item with type ZZTC is not gettting added to that delivey .
    for exmaple
    sales order 1234
    item category ZPU
    item category ZZTC
    delivery created with only one item ZPU
    May i know any requirments (routines ) are thre to solve this in VOFM .
    let me know how to hanlde this issue .
    Moderator Message: Spec-dumping is not allowed
    Edited by: kishan P on Oct 14, 2010 4:31 PM

    Hi Mohanty,
    I think the Immediate Delivery under Shipping for that order type may have value A or X, Clear that value.
    1) Goto VOV8 tansaction.
    2) Select the Sales order type (For eg: OR for standard order) and double click on that
    3) Under Shipping tab, Set Immediate Delivery with Blank value
    Plz reward points if it is helpful
    Thanks,
    Vinay

  • Image resize quality not saved in Save For Web Preset?

    L.S.,
    I have been working on an Action to create 12 separate PNG's for further use in my icon-software. What I do is basically this:
    Start out with a 256x256px image, save it for web four times in steps from 256, 48, 32 and 16px, (32-bit)
    apply some masks / layers, save it for web again four times from 256-16px,  (8-bit)
    set the mode to indexed colour / apply other masks and layers, and save it for web again from 256-16px. (4-bit)
    I let the sizing be done in the Save for Web step.
    The 256-sized pics give me no problem as they are not scaled down.
    The 32-bit pics give me no problem as they are scaled down, and antialias comes along, but they have 8-bit transparency: no problem.
    In the 8-bit and 4-bit versions from 48-16px, I definitely want no antialias in the sized down versions. So I set the resize quality to 'Nearest Neighbor'.
    However, Photoshop seems not to be able to remember different resize qualities in one Action.
    In every Save for Web-action that I do, when I set it to resize, it does so. But the resize quality is not taken from the setting. It seems to be taken from the last used or recorded setting.
    That is pretty annoying, because:
    - When I let the downscaled ones of the first 4, be downscaled 'bicubic sharper'
    - And I let the downscaled ones of the second 4, and third 4, be downscaled 'nearest neighbor'
    Next time I run the Action, all downscaling is done by 'nearest neigbor'. That ruins my downscaled 32-bit icons - they get jaggy.
    If I alter the steps in the action manually and set the first ones to 'bicubic sharper' again, suddenly all downscaled ones are done by 'bicubic sharper'.
    That ruins my downscaled 8-bit and 4-bit icons: they get antialias, to lime green, and that shows...
    I can save Presets in the Save For Web dialog, but as the groupbox already tells me: these presets only apply to the Image quality parameters, not to the sizing parameters. Those seem to be taken from the last run.
    I have one alternative to this: before every Save for Web step, I downsize the image myself, and undo the history step after saving. It's quite some work and I would just rather see that the sizing parameters saved in the Preset!

    That's never been saved as part of the S4W presets. Bloody annoying.

  • Adobe Edge Animate CC / 2014: Saving issue, program locks up when saving or Save-As

    Edge Animate CC (and CC 2014)  regularly freezes up when I hit save or save-as.
    When the programs does save without crashing/freezing it goes through a nail-biting screen flickering sequence, the mouse becomes inactive, the warning ‘( Not Responding)’ appears momentarily in the programme  bar, then the mouse becomes active again
    Also  as the project grew the programme became slow to respond when designing.
    The only way I can make any progress is to do incremental save-as every 10mins and half expect to loose what I’ve just worked on.
    I’ve tried updating from CC to CC 2014 , same issue.
    My system
    Alienware  Aurora R4
    Win 7 Pro
    Intel Core i7 3.60GHz
    16GB ram
    1TB HDD
    250BG SSD
    Any help would be greatly appreciated.
    Shaun

    Hi Sudeshna, thanks for replying.
    It's happening with a specific file, which is quite big, currently have around 90 graphics (png/jpeg) and 180 symbols in the project.
    In terms of features i've deliberately not used any Filters (invert, hue-rotate, contrast, etc) as they have issues in various browsers. I'm animating position and  along motion path, scale, rotation, skew, clipping, rectangle, circle rounded box, text, timeline-markers, code on symbols and code on timeline.

  • I can't open a web page saved with "save page as" from the Firefox (3.6.16) file menu. What gives?

    The icons for the saved page appear in the folder selected (e.g., Desktop)--and the default "whole web page" was selected in the "save as" box--but either double-clicking or right-clicking and selecting "open" on either icon leads to zippo. What am I doing wrong?

    Do you have any custom DNS settings on the devices that cannot connect?
    What happens If you connect to a different Wifi network outside of your home with any of the devices that can't open the website in your home, can you view the website?
    If you Ping the website from home what IP address does it attempt to ping?

  • Contacts saved through messaging in ios6 are not shown in contacts

    When i receive message from a new non-saved contact and i add it to contacts in messaging by clicking on add contact, it saves it. But when i goto contacts i found it disappeared. Whereas in messages it is shown as saved. When i try to edit it, there's no delete option at the bottom as well. Is it a bug in ios6. Its very much hesitating. I've synced facebook ad hotmail contacts. In contacts i've selected the option select all. Can anybody please solve my issue?

    hi!
    well i had the same "problem" but have you checked the format in which you saved your numbers. for example as you said you are using t-mobile austria whenever you save a number as 0699xxxxxxxx the iPhone usually wont show the caller id.
    what usually helps is when you always use the international-format
    for example if its an austrian number 0043 699 xxxxxxxx
    Or for a vienna-landline 0043 1 xxxxxxxx
    and so on and so forth. just try it with one or two contacts and see if that is solving your problem. it solved that problem for me and also somebody else.
    (by the way: im using t-mobile austria as well. but originally teh same happened to me with any other simcard i tried)
    hope that was of some help for you
    all the best und grüße aus dem 16ten

  • Cannot open a report I just saved via Save a Dynamic Template

    Hi All,
    I am on BPC 5.1 SP9, working in Office 2007.
    The problem is happen sporadically, where I save a report using Save a Dynamic Template.  Then try to open up the report I just saved, and the report does not open.  Sometimes if I resave the report via Save Dynamic Templates, I can reopen up the report.  If that does not work, I go back into Save Dynamic Template, and save it to a new name, and see if I can get the report to open.
    The strange thing is I can save the report to my desktop, then go into BPC.  Every time I open the report from my desktop it always runs.
    Not sure if anyone has seen this before?

    Does your template have an Excel 2007 4 digit extension? 
    There is a known issue with BPC 5.1 sp7 or higher service pack and Excel 2007 format extensions (SAP Note 1347243)
    Files with Excel 2007 Extension such as XLSX and XLTX, (saved and opened repeatedly via eTool -> Save / Open Dynamic Templates menu) may have issues where the template will not open.
    The problem does not exist with BPC 70M sp3 or higher. 
    The note also has a possible workaround; suggesting renaming the template on the File Share Server and then opening the re-named template via Open Dynamic Templates menu.
    Hope this helps.

  • RoboHelp 9 crashes frequently when saving or save all

    Hello,
    I'll try to give as much information as possible on this and hopefully someone will know a solution. If you need anymore information that
    I mght have forgotten, I'll gladly supply it.
    So, the basic problem is that RoboHelp 9 frequently crashes when I do a save or save all. 4 out of 5 times it won't crash, but usually after a few
    successful saves it will crash. And it crashes even more frequently when I insert an image, usually right after I insert the image and then save.
    So, here's the deal. The Sr. Tech Writer and I are both working on a small RoboHelp project that will demo a new Web Help Center for
    our company's customer facing website. There is already a very old Web Help Center on the website that was created with an older version
    of RoboHelp, and we're seeking to update that project. This involves importing the old HTML files from the old project into RoboHelp 9, and
    updating the existing files. We have two main project files at the moment and we are working out of a shared network folder. I know normally
    that working out of a network folder would be the issue, but his project has not given him any problems at all. My project is the only one that crashes when I try to save it.
    I honestly think it has something to do with the images, because we have to use SnagIt to take new screenshots. At first, I saved the screenshots to
    the SnagIt folder, but I thought that may be causing a problem in that RoboHelp couldn't save them in that location. So, I moved all the new screenshots associated with the
    project into the project folder and saved every new screenshot into the project folder. I also amde sure that none of the images were anywhere else in the local and network drive.
    That didn't solve the issue.
    I hope this makes snese. I don't know what else to try. If anyone knows another method I could try I'd greatly appreciate it. Thank you.

    Welcome to our community
    Man, I wish I had but a single nickel for every time I've seen someone in the forums say "it has worked just fine for years on the network, so it can't possibly be that. But oh, we are suddenly having all these issues..."
    The bottom line here is that you need to move the project from the network to the local C drive. Just try it. Won't take but a few moments to do. See if the crashes disappear.
    Odds are they will!
    And you will see an additional side benefit. RoboHelp will seem so much snappier as you work with it!
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Access denied error when saving (but saves document regardless)

    We have been getting a rather strange issue for a quite a long time with saving Microsoft Office documents. I suppose I should start with a rough background to our environment. I work for a multi-national company, that uses a mix of Windows 7 and XP machines
    running Citrix Xenapp to connect to a central Citrix hub, spread over several smaller individual servers, all running Windows server 2012, with a centralized file server for the company. The issue is only occurring in the UK offices (to my knowledge, and so
    far that I've seen only on the Windows 7 machines. 
    the error message itself, which is "The operation has been cancelled due to restrictions on this computer. Please contact your system administrator." which in normal circumstances, we would put down to permissions for the file. However, no matter
    the access granted to the file, be it full control and creator owner, this error will always appear. Once the message is closed, the file will save as normal, as if there was no issue.
    It only seems to be happening for a handful of users, on completely different servers. What makes this stranger is that it cannot be put down to a Citrix profile issue, or a software installation issue with Microsoft office, as other users on the same server
    as those who have this issue, encounter no problems at all, and a complete deletion of their citrix profile fails to fix it either.
    Does anyone have any idea what could be causing this problem? Any help or indication of where to begin looking would be greatly appreciated!
    Regards,
    Rich

    Hi,
    For your circumstance, I'd like to suggest you use Process Monitor to caputer system activity.
    Process Monitor:
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
    Note: use process monitor during save office document. After that, check its records.
    Roger Lu
    TechNet Community Support

Maybe you are looking for

  • A question about ActionListener and MouseListener

    Hi, my question here is when we should implement a MouseListener and when we should use ActionListener instead. I know ActionEvent is fired when a action performed, for instance, a button was pressed down, but I think by implementing a MouseListener,

  • Magic Mouse won't scroll in mail

    MAGIC MOUSE WON'T SCROLL IN MAIL IT WORKS FINE EVERYWHERE ELSE.

  • Can a form be created with a multiple-choice field?

    I would like to create a form letter and in the body of the letter, the user would select one of three options for the final paragraph.  Is this possible in pdf forms?

  • Employee selection table view not opening in MSS while selecting process

    Hello Everyone,   In MSS, Team->Start Process for Employee Employee selection table view is not visible, so without selecting employee if i click Select Process button its telling employee is not selected.. How make that Employee selection view visib

  • How does Rehearse Slideshow work?

    I've put together my first presentation on my MacBook Air. When I select Play Slideshow, my whole screen fills up with the current slide, one at a time. When I select Rehearse Slideshow, I can see the current and next slide, plus the timer etc. But w