Code will not write to text

Hello to all:
Can someone give advice to why the code below will not write to the text that I save. In other words, when I write a text file then save it then open the text file again, all of the words that I have written are not seen.
     private File workingFile = null;
  private JTextArea jta;
private void saveFile()
               if (workingFile != null)
                    try
         FileOutputStream fos = new FileOutputStream(workingFile);
                         fos.write(jta.getText().getBytes());
                         fos.close();
                                        //write the file out through FileWriter
               PrintWriter outFile = new PrintWriter(new FileWriter(workingFile));
               outFile.print(area.getText());
               outFile.close();//close the text file
                    catch (IOException e) { e.printStackTrace();
               else
       JFileChooser jfc = new JFileChooser();
               jfc.setDialogTitle("Save Document");
               int option = jfc.showSaveDialog(null);
               if (option == JFileChooser.APPROVE_OPTION)
               try
          FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile());
                         workingFile = jfc.getSelectedFile();
                         fos.write(jta.getText().getBytes());
                         fos.close();
                    catch (IOException e) { e.printStackTrace();
          }

ok, I found the line that is causing the exception. Line333 which is in
the second if statement , the following:fos.write(jta.getText().getBytes());
Now how would I fix that besides deleting itCan you post the first few lines of that stacktrace? Either jta or fos
(or both) are null; the stacktrace shows you which one caused the
NullPointerException.
Of course you can add a few debug prints just before that line:System.out.println("jta: "+jta);
System.out.println("fos: "+fos);kind regards,
Jos

Similar Messages

  • My Mac OS X 10.4.11 will not write DVDs and gets error code 0x80020022, what is wrong?

    My Mac OS X 10.4.11 will not write DVDs and gets error code 0x80020022, what is wrong?

    That code is not really useful since it just means it can't write DVD's (or probably CD's).  The only thing you can do is first to try a different brand of DVD's, higher quality.  You could also try burning at a slower speed.
    Based on the fact that you are using an OSX that's no long supported, there's probably not much you can do to correct this issue if it is software related.  You may also have a failing Super Drive, another consequence of an older Mac.

  • Maxl Script will not write to error file for data laod.

    Sorry Glenn here is the new thread. I re ran without the semi colon after data 3 and the same error came up without anything being written to the error file.
    I purposely removed a member from the orginal outline that is included in the data loaded but yet the error file is not written to. I tried doing the load manually but executing it in the background, error file is to be created on my local HD but it does not write it there. Checked the output and it is written to a directory located on the server. Although i think this is normal.
    Could it be that it will not write to a local drive? I am going to try specifying a spot on the server to see if it runs there.
    thanks
    Original post below.
    Hello,
    I am also having this issue.
    I will include my script below but will state some details before
    We are on Essbase 11.1.1.3
    I am running Admin Console from my client PC that connects to the server in the script and I read that in this set up the error file will not get written to. This documentation was for v 9.1.3
    Here is my script (i changed some of the names)
    login 'user' 'password' on server';
    create application 'Money1' as 'Money2';
    spool stderr on to 'errorfile';
    import database 'Money1'.'Main' data
    from local text data_file 'Money1_Data.txt'
    using server rules_file 'Data3'
    on error append to 'dataload.err';
    execute calculation 'CALC ALL;' on 'Money1'.'Main';
    logout;
    spool off;
    exit;
    here is the error output i get:
    code line: on error append to 'dataload.err';
    Statement executed with warnings.
    (3) Syntax error near ['$']
    I don't see a dollar sign anywhere in my code and the error file does not get produced.
    Also do error files get written too if the actins are executed in the background?
    Thanks!
    Alex

    This works for me in a MaxL script run through essmsh.exe:
    import database appname.dbname data from local text data_file "d:\\datafilename.txt" using server rules_file "rulename"
         on error write to "d:\\errorfilename.err" ;Sometimes EAS (I think you are running it through that) does weird things to MaxL. I eschew MaxL in EAS as much as possible (like 100% of the time).
    NB -- the datafilename and errorfilename and their drive letters are local to wherever you're running this process through the MaxL shell. I don't know how that works when you're running EAS -- are drives local to your session, local to the EAS server? Dunno. Leave EAS behind, buy TextPad (no I am not the author of that fine product) and download the MaxL syntax library, and be happy. :)
    Regards,
    Cameron Lackpour
    Edited by: CL on Oct 7, 2010 7:12 AM
    Put the MaxL into a code block to get it to display correctly.

  • Problem with shuffle() code, will not compile

    Hi,
    Below is some code designed to shuffle a set of integers in the file editET.txt. Basically:
    5
    2
    4 say:
    just shuffle these randomly around, however, the code will not compile, any advice or solutions would be great
    import java.io.*;
    import java.util.*;
    public class Shuffle3 {
    public static void main (String [] args) {
    if (args.length<2){
    System.out.println("Usage: java Shuffle3 <input file> <output file>");
    System.exit(-1);
    ShuffleStringList sl = new ShuffleStringList(args[0]);
    sl.shuffle();
    sl.save(args[1]);
    class ShuffleStringList extends StringList {
    public ShuffleStringList(String "editET.txt") {
         super(fileName);
    public void shuffle() {
    Collections.shuffle(this);
    public void save (String "Shuffledok"){
         PrintWriter out = null;
         try {
         out = new PrintWriter(new FileOutputStream("Shuffledok"), true);
    for (int i=0; i < size(); i++){
              out.println((String)get(i));
    catch(IOException e) {
    e.printStackTrace();
    finally {
         if(out !=null) {out.close();}
    class StringList extends ArrayList{
    public StringList(){
         super();
    public StringList(String "editET.txt") {
         this();
    String line = null;
    BufferedReader in = null;
         try {
         in = new BufferedReader(new FileReader("editET.txt"));
         while((line = in.readLine()) !=null) {
              add(line);
    catch(IOException e){
         e.printStackTrace();
    public void save (String "Shuffledok") {
    FileWriter out = null;
    try {
         out = new FileWriter("Shuffledok");
         for(int i =0; i < size(); i++){
         out.write((String)get(i));
    catch(IOException e){
         e.printStackTrace();
    finally {
         try{out.close();} catch (IOException e) {e.printStackTrace();}
    public void shuffle() {
    Collections.shuffle(this);

    import java.io.*;
    import java.util.*;
    public class Shuffle3 {
    public static void main (String [] args) {
    ShuffleStringList sl = new ShuffleStringList("editET.txt");
    sl.shuffle();
    sl.save("Shuffledok");
    class ShuffleStringList extends StringList {
    public ShuffleStringList(String fileName) {
    super(fileName);
    public void shuffle() {
    Collections.shuffle(this);
    public void save (String target){
    PrintWriter out = null;
    try {
    out = new PrintWriter(new FileOutputStream(target), true);
    for (int i=0; i < size(); i++){
    out.println((String)get(i));
    catch(IOException e) {
    e.printStackTrace();
    finally {
    if(out !=null) {out.close();}
    class StringList extends ArrayList{
    public StringList(){
    super();
    public StringList(String fileName) {
    this();
    String line = null;
    BufferedReader in = null;
    try {
    in = new BufferedReader(new FileReader(fileName));
    while((line = in.readLine()) !=null) {
    add(line);
    catch(IOException e){
    e.printStackTrace();
    public void save (String target) {
    FileWriter out = null;
    try {
    out = new FileWriter(target);
    for(int i =0; i < size(); i++){
    out.write((String)get(i));
    catch(IOException e){
    e.printStackTrace();
    finally {
    try{out.close();} catch (IOException e) {e.printStackTrace();}
    public void shuffle() {
    Collections.shuffle(this);
    }

  • Air App will not read local text file using openAsync/readUTFBytes on user (non-admin) mode

    I am running an Air App I did for the desktop, from the actual installed executable already deployed in the machine (Not from Flash Pro / Flex dev. environment). For some reason the app will not read a text file stored in the same application folder unless I run my app as administrator from the OS.
    When I run the app as admin, or within the development environment it works fine. Maybe this is related to some security issue? I read the adobe air documentation, and this should work...
    I am using openAsync/readUTFBytes on user as shown here:
    var continueGamesConnection:FileStream();
    var continueFile:File = new File(File.applicationDirectory.resolvePath("continueGames.txt").nativePath.toString()); 
    continueGamesConnection.addEventListener(Event.COMPLETE, openSavedGames);
    continueGamesConnection.openAsync(continueFile, FileMode.UPDATE); 
    function openSavedGames(event:Event):void
         continueGamesConnection.removeEventListener(Event.COMPLETE, openSavedGames);
         var content:URLVariables = new URLVariables();
         var loadedContent:String = new String();
         loadedContent = continueGamesConnection.readUTFBytes(continueGamesConnection.bytesAvailable);
         content.decode(loadedContent); 
         variableX = content. variableX
         //etc, etc. 
         continueGamesConnection.close();
    By the way, I have also, tried using FileMode.READ, and others, and it still gives me the same problem. Only works if ran on admin mode or from the dev. environment.
    It's very frustrating, I tried reading other posts without any luck... What solutions do people use for this kind of problem?
    I have seen that you can set the app to run as admin somehow, and I guess that could work. However, this should work just fine, since it doesn't seem to violate any of the security APIs of Air. Seems like an overkill. But even so, how do I do that?
    You help is greatly appreciated!

    Thanks kglad.com. I will try this and see if it works. Can you check my code a bit to see if it's right?
    var continueFile:File = new File(File.applicationStorageDirectory.resolvePath("savedgames/continueGames.txt").nativePath.toString());
    Does this look right to work across all desktop OS?

  • Edge Code will not load in web browser

    My OEM edge code will not load in web browser after it has been uploaded to the server. I am using dreamweaver & the OEM file.
    The images are all grouped & labeled properly (within Edge Animate). Note the website will not load with ANY web browsers UNLESS you hit the refresh button or reload the web address.
    www.anndominion.com
    Can somone please tell me what is going on or how to fix the problem? ;(
    Here is the code for the website too.
    Any help would be great!
    <!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
    <title>Welcome</title>
    <!--Adobe Edge Runtime-->
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <script>
      var custHtmlRoot="edgeanimate_assets/Home/Assets/";
      var script = document.createElement('script');
      script.type= "text/javascript";
    script.src = custHtmlRoot+"edge_includes/edge.5.0.1.min.js";
      var head = document.getElementsByTagName('head')[0], done=false;
      script.onload = script.onreadystatechange = function(){
      if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
      done=true;
      var opts ={
        scaleToFit: "width",
        centerStage: "none",
        minW: "0",
        maxW: "undefined",
        width: "1500px",
        height: "800px"
      opts.htmlRoot =custHtmlRoot;
      AdobeEdge.loadComposition('Home', 'EDGE-292846011', opts,
      {"style":{"${symbolSelector}":{"isStage":"true","rect":["undefined","undefined","1500px", "800px"],"fill":["rgba(255,255,255,1)"]}},"dom":[{"rect":["716px","356","88px","88px","aut o","auto"],"id":"preloader5","fill":["rgba(0,0,0,0)","images/preloader5.gif","0px","0px"], "type":"image","tag":"img"},{"rect":["645px","480px","229px","79px","auto","auto"],"font": ["Arial, Helvetica, sans-serif",[24,""],"rgba(0,0,0,1)","normal","none","","break-word","normal"],"id":"Text" ,"text":"Please Tap Refresh <br>To Load Content.","align":"center","type":"text"},{"rect":["555px","283px","361px","103px","auto" ,"auto"],"font":["Arial, Helvetica, sans-serif",[24,"px"],"rgba(0,0,0,1)","400","none solid rgb(0, 0, 0)","normal","break-word","normal"],"id":"Text2","text":"","align":"center","type":"text" }]}, {"dom":{}});
      script.onload = script.onreadystatechange = null;
      head.removeChild(script);
      head.appendChild(script);
      </script>
    <style>
            .edgeLoad-EDGE-292846011 { visibility:hidden; }
        </style>
    <!--Adobe Edge Runtime End-->
    </head>
      <body>
        <div id="Stage" class="EDGE-292846011"></div>
        </body>
    </html>

    Keith,
    Make sure the Cluster configuration is right. When did you start seeing this problem?
    Host A: Dispatcher->server 0, server 2
    Host B: Dispatcher->server 0, server 2
    i.e The instance IDs are mapped right.
    Also try to hit the individual servers in the cluster the following way.
    http://hostname1:50000/irj/portal;sapj2ee_irj=instance_id sends a request to server 0.
    http://hostname2:51000/irj/portal;sapj2ee_irj=instance_id sends a request to server 1.
    This may give more clues. Unfortunately I don't have access to EP6 SP2 to lookup and tell you the right parameters to look for.
    Regards
    -Venkat Malempati
    Message was edited by: Venkat Malempati

  • IPhone 4s will not let me text to one phone number

    My iPhone 4s will not let me text to my brother's phone number.  It keeps giving the message "Error Invalid Number.  Please re-send using a valid 10 digit mobile number or valid short code."  I have rebooted my phone; same problem.  I checked the number; it is correct with area code and 7-digit number.  I have no trouble texting anyone else in my contact list.  The number is not blocked. 

    I'd head to an Apple Retail Store or contact AppleCare at 1-800-275-2273

  • HT201401 4s with latest software update will not power off, text will only vibrate, iPod only works with earphones. When I sync it with iTunes it works until power save mode starts, then back to not powering down, making text sounds, or playing iPod out l

    4s with latest software update will not power off, text will only vibrate, iPod only works with earphones. When I sync it with iTunes it works until power save mode starts, then back to not powering down, making text sounds, or playing iPod out loud.

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414
    If you try all these steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

  • When using spotlight search on my 5s it will not show past text messages that haven't even been deleted even if I type a specific word that I know is in a message I want to search for. I have message search turned on in the spotlight settings.

    When using spotlight search my phone will not show all text messages with a common word even though I have not deleted any messages from my phone and I have the message search turned on in settings under spotlight search. The search only shows the messages that are recent within the past day or so. Why won't it show the other messages when I search for them even using a specific word that I know was in the message I'm searching for.

    Hello ChiomaM,
    It sounds like you are not getting notifications for new text messages that are coming in, and you must manually check the app. I recommend checking the Notification settings to see if they are configured correctly:
    iOS: Understanding notifications
    http://support.apple.com/kb/ht3576
    iOS apps can provide three types of notifications:
    Sounds: An audible alert plays.
    Alerts/Banners: An alert or banner appears on the screen.
    Badges: An image or number appears on the application icon.
    You can view which apps provide notifications and adjust notification settings using Settings > Notification Center. For additional information, refer to the user guide for your device.
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • IPhoto 9.2 photo descriptions will not write - after a few letters words self erase!

    iPhoto 9.2 photo descriptions will not write - after a few letters words self erase! Program update downloaded earlier today, 24.10.11. Fine on my laptop, but my desktop is having problems.

    Rebuild the main library.
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • When I click "Buy Now" in iPhoto's book I get the following message: Your book appears to have default text that has not been edited. Printed books will not include this text. Do you want to continue?"

    When I click "Buy Now" in iPhoto's book I get the following message: "Your book appears to have default text that has not been edited. Printed books will not include this text. Do you want to continue?"
    How do I proceed?  How do I identify which is "default text?"

    What version of iPhoto are you using?
    Go thru each page, check the layout to see if there's a text box included on the page and make sure there is text in that text box.  If not it may show the "holding" text like this:
    If you don't want to change the page layout to one that only has photos and no text boxes just select that holding text and put a space in its place.
    OT

  • When I click Buy Book this appears our book appears to have default text that has not been edited. Printed books will not include this text. Do you want to continue? will the text I have sellected still be ok or will the book have missing text help Pleas?

    I just spent 3 days creating a book [32 pages], with photos and text but when I click Buy Book In iPhoto this appears>
    Our book appears to have default text that has not been edited. Printed books will not include this text. Do you want to continue?
    My question is will the text I have sellected to use still be ok, am I safe to continue and buy or will the book have missing text ?
    The book is for special birtday in 2 weeks time  Please Help.G
    <Email Edited by Host>

    Yes, you're safe to continue.  That means that there are text boxes that you did not put any text into and they contain the holding text which will not be printed.  That text is shown in a light grayt and is in Latin.  Normally you can just put a space in the text box to replace the holding text so as not to get that warning message.
    Before ordering the book proof the book according to this Apple document: iPhoto, Aperture: Previewing an order in iPhoto or Aperture. Check the pdf file for any missing text or photos and any warning indicators in the text boxes indicating that some of the text has exceeded the space allotted in the text box.
    Keep the pdf file to compare with the printed copy when you reciive it.
    OT

  • How can I fix the text in my photo book that reads"your default text had not been edited. Printed books will not include this text?"

    How can I fix the text in my photo book that reads"your default text had not been edited. Printed books will not include this text?"

    You will get this warning, if your book includes textboxes that still include the default text, like "Insert Title". You need to find these boxes and add your own text.  Look for boxes like this:
    Make a PDF-preview of your book and look, where the preview differs from what you are seeing in iPhoto.
    iPhoto, Aperture: Previewing an order in iPhoto or Aperture

  • OPC will not write to AB L32E - Will Read

    OPC will not write to AB L32E - Will Read.
    I have been able to set up a OPC Server using the NI OPC Server, using the ControlLogix Ethernet driver for the AB 1769-L32E PLC.
    All of the tags can be seen. The Lookout 6.7.1 will see real time data, but anything I write too, never shows up in the PLC.
    Using the OPCclient in Lookout. Their is No alarm's, other than a value has been adjusted by direct user input..
    Their is no comm errors.
    I just purchased this software last month.
    The NI OPC Server, Events, no errors.
    Thanks.
    Dave
    Solved!
    Go to Solution.

    Thanks for your posts because I knew this should be possible.  Here is what I found.  Check step 4 of your channel in case your value updating is wrong or Step 11 of  device is set to do not create on startup.
    Thanks to the folks at Kepware. I was able to get this working for CompactLogix L32E.
    Step 1: In NI OPC Server Create a new Channel. Channel Name can be whatever you want.
    Step 2: Device driver will be ControlLogix Ethernet.  You can also enable diagnostics if you want.
    Step 3: Network adapter. I used default setting.
    Step 4: Write only latest values.  Duty at 10. ( These are default settings and are recommended.)
    Step 5: Finish new Channel setup
    Step 6: Click on Icon to create new device
    Step 7: Device Name can be whatever you chose.
    Step 8: Select Device Model in this case CompactLogix 5300
    Step 9: Device ID For me was IP Address XXX.XXX.XXX.XXX,1,0    (Note the 1 directs path to backplane. The 0 to the slot where processor is)
    Step 9: Device timing.  Leave at defaults.
    Step 10: Auto demotion leave unchecked.
    Step 11: Leave at defaults Do not generate on startup Delete on create and allow subgroups
    Step 12: Port and watchdogs at default settings
    Step 13: Project options leave at default. (In my case I changed to short as that is what most of my tags were)
    Step 14: Create tagname from device.
    Step 14: Finish Device setup.
    You now have two options. 
    Option 1: Start creating tags as you need them. (This is what I did)
    Option 2: Right Click newly created device and select properities.  Then select database creation and click auto create.
    Go To Lookout  and create new driver. 
    Select OPC Client
    Server name will be from dropdown menu. National Instruments:NIOPCServers
    Click okay
    You should be done and smiling. 

  • Help to restore my iphone and it will not write error 1002

    help to restore my iphone 3gs and it will not write error 1002

    Click 1002 >  iOS: Resolving update and restore alert messages

Maybe you are looking for

  • IChat not connecting

    I've been using iChat to videoconference with my parents in France for 6 years now. iChat has usually run smoothly (except for occasional problems with the Internet provider), but for the past couple of weeks, when I call, the line says "Starting vid

  • How do I make a video clip appear smaller in Adobe Premiere 6.5?

    Hello, I am attempting to make a video clip appear smaller with a black background, the way movies often do when they show out takes at the end during the credits. I'm sure this is something pretty simple, but I can't seem to figure it out. Any assis

  • Smart mailboxs does not show any content.

    I have a 27" iMac, late 2009, running iOS 10.10.2.  None of my smart mailboxes show any content.  I have rebuilt my mail and checked the smart mailbox conditions.  I created a new smart mailbox, Unread, Delivered this week, and still no content.   Th

  • X120e audio issues

    Greetings, I have an x120e that I bought in August (8GB Ram upgade).  I have been having some audio issues whilst doing some light audio editing in Audobe Audition (CS 5.5) and listening to music. When my internal speakers are playing sound, it frequ

  • MDM Login and Closing Problem

    Hi All, When I am trying to login in MDM I am getting following message *" RFC connection is failed....... Please contact to system administrator."* Some time when there are more than 10 users or when MDM is idle for some time then _MDM session is no