Text is not saved in file...WHY ?

Hi everyone,
I made a simple text editor using Swing. It has only a JTextArea as the main text processor.
I have added a File menu where I can open or save files with the JFileChooser class.
The code I am using to save data from the JTextArea to a text file say abc.txt is as below :
try
File file = new File(fname);
file.createNewFile();
StringBuffer sb = new StringBuffer();
sb.append(textPad.getText());
PrintWriter pw = new PrintWriter(new FileWriter(file));
pw.write(sb.toString());
catch(IOException e) {}
The file is being created with the specified name but no text is being saved in it even though there is valid text in the JTextArea textPad.
Can anyone help me as to where the fault lies in the code ?
Thanks alot.

Hello guys,
I have the same problem but I want to use println() instead of write(). Is it possible? And furthermore, if I have write operations in a loop, does the flush() operation have to be performed after every write() or once before close? I tried both things at the same time but yet, I can't see anything to be written to the file. I haven't tried yet the write() method but I think the println() method should work just fine...
The writer I use is formed like this:
PrintWriter coordinatesPrintWriter = new PrintWriter(new BufferedWriter(new FileWriter(coordinatesFile)));where coordinatesFile is a File.
then in a loop I do
try
for(...)
coordinatesPrintWriter.println("A string, ctra");
coordinatesPrintWriter.flush();
coordinatesPrintWriter.flush();
coordinatesPrintWriter.close();
catch(IOException ioe)
JOptionPane.showMessageDialog( GraphManagerGUI.this, ioe.getMessage(), "IO ERROR", JOptionPane.ERROR_MESSAGE);
}But nothing is outputted to the file, although created.
Do I forget to do something? Should I close all wrapped writters? (although I don't really think this is the problem...)

Similar Messages

  • IPhoto will not open iDraw files - why are the files "unrecognized"?

    iPhoto will not open iDraw files - why are the files "unrecognized"?

    What file format are you saving the files as?
    OT

  • How do i delete files in pages, i have some old invoices in pages that i want to delete, i can delete the text but not the whole file, please help. Dennis

    As it say's above i need to delete some of my oldinvoices/estimates from my files in pages, i can get rid of the text but not the whole file, thanks Dennis

    You locate the file in the Finder(it's in the Documents item of the sidebar by default), drag it to the Trash, and empty the Trash.
    (59926)

  • PSE not saving edited files to the organiser

    For no apparent reason my PSE 11 application seems to have developed an annoying glitch whereby part way through an editing process it stops doing as requested in the "Save" options, by not saving edited files as version sets of the original file in the Organiser. The files are saved OK to My Pictures and I then get advised that a file is available to import and I have to import each one, stack it with the original, and put the edited file on top. This is driving me nuts as I have about 1000 photos to edit. What is causing this problem? My only thoughts are that I have c.30000 picture files in the Organiser (but this hasn't caused any problems in adding new files)  and that the problem seems to have arisen since I started editing files directly from within an Album.
    Help

    It's the first time I see that bug mentionned in PSE11, but it's an acknowledged bug in PSE12.
    See that post with links for the workarounds:
    http://forums.adobe.com/thread/1328850

  • When i am trying to download something it is diaplaying downloads window but not saving the file in that why?

    i tried cache clearing and application tools settings and all.
    it is asking for want to save ur binary file eventhough i press save button also it is not saving anywhere please resove my problem as soon as possible. And i tried pop3 blockers settings also but of no use.

    See:
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • Text layers not saved correctly as PDF from PS?

    I frequently save layouts I do in Photoshop as PDF's. Lately I very often will discover the text does not display correctly in the PDF. One or two lines of text will display as white with a thin black outline, rather than as the basic solid black I'd specified.
    I work on a Windows 7 machine with the current version of PS. The text is on layers when I save the file to PDF (from PS), but I do not include the layers in the PDF, so they should be flattening down.
    Any ideas why this happens? I noticed a few weeks ago when it was also doing this that I updated the program a day later and the PDF's were not exhibiting this issue. But, now it's starting again. A big timewaster for me.
    Thanks for any suggestions offered.

    Text doesn't flatten until you tell it to. In fact that may be the problem here - you are telling the PDF maker to not retain vector text and when it tries to flatten, some layer style or something else gets in the way. Try to play with the PDF options. also manaulyl flatten the document in PS before saving to PDF...
    Mylenium

  • AE CC 2014 Export to C4D not saving any file

    I just got into CC (was using CS6) and today I wanted to export a C4D file from AE, like I have done always with AE CS6, but there seems to be a problem. I click on export, Maxon Cinema 4D Exporter, then select the folder and type the file name, click save and it closes like normal, but the file I supposedly saved, is not created anywhere. Anyone has the same issue?

    Apparently the problem is with the folder I was saving the file. I saved it to another hard drive and it saves the file just fine. Is there a limitation for a folder structure?
    Another issue is that the scene only includes the camera and not the solids or text layers. If I export from AE CS6 it includes all that.

  • Big problem: KN08 not saving KN06 files

    Hi everyone,
    I have a big problem with keynote 08 (4.0.1). Antefactum: last year our department finally migrated from powerpoint (mac, obviously) to keynote (3.0.2). So I opened all our powerpoint courses and conferences in keynote and saved them as keynote files, fixed all the little problems due to conversion and happily started to use only keynote. In december we updated to Leopard and KN 08, and here started the problem: if I create new files in KN 08 everything works perfect; I can create a new presentation, save it, update it with new material and save changes. Instead, if I open one of our KN 3.0.2 presentations in KN 08 he lets me do every modification but when I try to save it as KN 08 he tells me that it’s not possible. This is pretty frustrating, because I have something like 1 Tb of presentations and I don’t need to create new ones from zero, I need to update the existing ones with new material. Anyone knows why on earth KN 08 doesn’t let me do this? I mean, I can’t believe Apple programmers didn’t notice this problem, and I don’t want to think they thought this “function” would be fine either. If it’s a bug, anyone knows how it can be fixed?
    Neptune

    Hi Kyn Drake,
    first of all let me thank you for the answer I updated to KN 4.0.2 but the problem remains. The message I get is "impossible to save document "(filename)", or "impossible to save document "(filename)" as "(new filename)", in case I try to save it with the same name or with a different one. This happens also if I do not modify a presentation at all: that is to say, when I open one of my presentations in KN 08 the red button in the upper left corner of the window already has the dot inside, which means that the document "is not saved". If I just try to save without doing anything to the presentation it still presents the problem. It doesn't even allow me to export it as a powepoint, I tried and still it says it is impossible. I can't really understand why, and I can't think I'm the only one who has this problem ?!??

  • SQL Profiler running trace - where do the rows go if not saved to file

    When SQL Profiler trace is running, there are thousands of rows generated and shown in the trace window. Since I am only looking for deadlocks, I am not saving them. Are they just discarded, else where do all those rows go? I really don't want to fill
    up the log file.

    From your description, it seems you are running Profiler while saving events to a file.  All of the displayed events are also written to the file.  If you don't need events other than deadlocks, you should not include those in the trace to begin
    with.
    Be aware that a Profiler trace can significantly degrade server performance when many events are captured.  If you must capture a large number of events (or run a trace continuously), I suggest a server-side trace (or Extended Events file target)
    instead.  This will allow SQL Server to stream data directly to the trace file without the Profiler tool overhead.  You can script the Profiler trace for server-side tracing from the Profiler File-->Export menu.  Save and customize the
    script (file name, max file size, etc.).  You can view the trace file(s) using Profiler or fn_trace_gettable.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Text Stroke not coming ... why ?

    Hi, I'm selecting the outline color of my text, but nothing is showing ? Why ?
    Regards,
    Frank

    A hard edged glow is probably the closest you'll come.  Unfortunately, Flash is not yet intended as a graphics tool, although I often find it suits my needs without any need to look to graphics software.

  • Today firefox didn't open .htm file saved in my computer how to solved the issue? yesterday opened perfectly yet today not opened .htm file why?

    IN BANK WEBSITE TAX PAID PAGES SAVED IN MY COMPUTER AS .HTM file format since yesterday firefox, chrome opened this files perfectly. yet today i have not open this type of files. open the .htm file firefox opened in home page only.

    If you drag and drop the .htm file on page currently displayed in a Firefox tab, does it display correctly?
    If so, this implies that there is a problem passing the file name to Firefox, either a problem with the registry settings created whenever you make Firefox your default browser, or an issue with how Firefox is starting up.
    Assuming you still have Google Chrome installed, could you do a double-switch of your default browser:
    # Have Google Chrome make itself the default browser (see [https://support.google.com/chrome/answer/95417?hl=en Make Chrome your default browser - Chrome Help])<br><br>
    # Have Firefox make itself the default browser again (see [[How to make web links open in Firefox by default]])
    Any improvement?

  • Xcode not saving source files

    Hi
    Has anyone else come across an issue where Xcode doesn't save source files before a build - despite setting the For Unsaved Files preference correctly?
    My Java students are using Xcode 3.1.1 to create and build Java Tool projects. We've noticed that we can't modify the default source file for a newly created project, nor can we modify any new source files we add to the project UNLESS we close down and restart Xcode after adding each new file. Specifically, any edits are stored in the file buffers but these are not automatically saved to the hard disc when we trigger a build. However, once Xcode is closed and restarted, all source files in the project behave normally.
    Interestingly, the problem doesn't seem to happen with Tool type projects in other languages, however, these projects by default put the source files in the top level of the project folder, whereas all Java projects put the source files one level down in a "src" sub-folder.
    Has anyone else noticed these issues with Java projects? Do similar problems occur in other languages if source files are stored in sub-folders? Remember, the problem only exists for newly created files and it's resolved once Xcode is shut down and restarted - unless, of course, we need to add more files.
    Anyone got any workarounds which avoid stopping and restarting Xcode?
    Bob
    PS: Please don't post comments saying that I should use Eclipse, Netbeans, BlueJ, etc That's not relevant to this discussion.

    Thanks briyu. At least you've confirmed that I'm not going mad
    As for 3.1.0, that's what the student machines are using and we have the problem there. I wonder why no one else has reported this before? Probably Xcode isn't used very much for Java.
    Bob

  • With LR 3.4.1 my keywords are not saved to file

    Since upgrading to LR 3.4.1 my keywords are no longer saved to the files so I can not see them in an external application. If I revert back to LR 3.3 it works OK. Any ideas?
    I have the option set to automatically write changes into XMP.
    I tried to write metadata to files manually and that does not work either.
    The files are .jpg
    I'm using a Windows 7 32bit PC.
    Thanks...

    External drives often have special ACLs on them that can cause access problems for some apps. All it takes is for Lr to change how it accesses file and file metadata (even a change that made it more "correct" -- i.e., a bug fix for some other problem) and it can uncover ACL issues.
    I don't know what you would have to do on Windows to remedy this, but on a Mac, I would make sure that the drive is setup to be "shared" so it has additional special ACLs on it that allow ownership to be taken.
    But, you want to start at the root of the drive, and reset ALL the ACLs (NOT just the "permissions" which are older, simulated and incomplete settings, and making sure to recurse through the entire folder structures) such that the owner/creator and admins have full control. There may be other special ACLs required if you want to share this disk with different users on different machines. This part I am not familiar with, but it comes up often on Windows support sites. Look or people having similar problems with Windows remote disk services.
    Remember, if you have a login on two different Windows machines (assuming you do not have some sort of network-wide login) this is technically two different users (even if they have the same name).

  • GPS data in Aperture not saved to files

    Hi there
    I have been using Aperture for a while and love it! Recently I purchased a DSLR and upon importing into Aperture, I manually added the locations to the files. Whenever I view the places feature for my library, I can see pins on the map so I know its been saved correctly.
    When I imported the files, I ensured the import was "file system" and so hopefully Aperture doesnt save it into it's own library.
    Unfortuantely, when I try and view the EVIF GPS data in Photoshop for these files, the GPS value is empty. If I manually export the file, the data is there, but somehow the files are smaller in file size (even though I chose JPEG Original Size).
    Is there a way for me to make GPS changes in Aperture and for it to be automatically saved to the actual file instead of me going through the process of exporting it?
    Thanks!

    Aperture does write the GPS data only to the versions, when you are assigning a place, not to the EXIF tags of the original files.
    So you will need to export the edited version to write the GPS to an image file.
    If I manually export the file, the data is there, but somehow the files are smaller in file size (even though I chose JPEG Original Size).
    "JPEG Original Size" refers to the pixel size, not the file size. You could try to increase the image quality settings in the "JPEG Original Size" export preset. Select this preset in the export panel and then switch to "Edit". This will allow you to increase the "image Quality" by adjusting the slider. Or select a "Tiff" preset, to export losslessly.
    Another work-around would be to use exiftool to set the GPS tags on your originals, if you are experienced with the Terminal (see:                  Modifying EXIF tags of Originals Using exiftool: camera, lens, gps)
    I usually do the geocoding before importing the image files to Aperture with Jetphoto Studio, but that is not a free application.
    Regards
    Léonie

  • OS X Server not saving my File Sharing settings

    Hi there,
    Hoping there is someone out there who can help as there are a few head scratching issues going on!
    Basically the main issue I am getting is to do with File Sharing in OSX Server.
    I have two raid servers set up with a mac mini server acting as the link to the main network. I use GlobalSan Xtarget to mount the Raids.
    I have set up OSX Server primarily so that I can use the VPN function on the Mac Mini, otherwise it is a very simple set up. However, when I attempt to change the settings of my second raid, (As Displayed) clicking ok doesn't save the settings or infact close the window, it just does nothing, with no warning errors as to the reason why. What I am trying to do is remove allow guess users access to this share.
    Now your probably thinking why don't I just remove the opportunity for a guest to log into the server, while yes this will work, it's just that I am getting other issues that I am wondering is linked to what is happening In OSX Server.
    For instance, I have a Capture One Catalog archive which is supposed to link to a selected folder on my raids. One is for my commercial work, and one for personal. I have a raid for Commercial Work which works completely fine (All the images display and import into the catalog), and a raid for Personal Work (The raid with the file share issues in Server). When attempting to import the images from the Personal Raid, it doesn't recognise them, it knows they are there, but it doesn't recognise it as an image file. However, you can view them fine in Finder.
    I thought it was maybe a Sharing and Permisions issue, so I matched the settings from the Commercial Raid with no success. So I am wondering if it is to do with this issue I am having In OSX Server.
    To add to these points, I am also getting an Unknown User showing in the User list for the Commercial Raid, not that it seems to be causing a problem, but it is another thing thats happened since migrating the server from 10.8 to 10.9.
    Any help will be greatly appreciated!
    Thanks in advanced.
    Aaron

    Ok so I've solved the Capture One Issue, it was due to the / in the Personal/Moving name of the Raid, so that is all fine.
    But if anyone does know why server won't save the File Sharing issues, and the issues with the Unknown User, it will still be a great help!
    Many thanks,
    Aaron

Maybe you are looking for

  • Losing 1:1 previews in LR 5

    When using photoshop lightroom 5 CC on Mac OS X 10.9.5, I keep losing my 1:1 previews for NO reason (happens about once/month)... I'd like to save my previews... Help?

  • Anyone else still having iMessage issues?

    I was having major problems yesterday then last night all was well.  Now this morning my imessages have reverted to being sent as text messages.

  • Alternative to union in Oracle 10g

    Below is the sql using union that I am using currently. There are 64 columns from 3 different tables. Out of all the columns only one column value is a constant to get 2 records. select col1, col2, col3,...., 'DE' medium_val from table1, table2, tabl

  • My ipad wont work. it ran out of batteries and now its stuck on the apple logo

    i just got my ipad less than two weeks ago, and i went to sleep with it on 27% charged. when i woke up it was out of batterie so i plugged it in, but it got stuck on the apple logo with the swirly thing and when i plug it in again, it just keeps maki

  • Reg:Tkprof, awr, explain plan, autotrace analysis

    hi friends. can any one give description about below subject.......... Tkprof, awr, explain plan, autotrace analysis if possible kindly mentioned some example for each OR provide some to read. regards, Rajnish