Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Need help with write to .dat file code from textarea

  1. #1
    Member
    Join Date
    Jan 2013
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with write to .dat file code from textarea

    I have other part of program reading from textField which works fine. My problem is i cannot get the textArea to do the same thing:

    ind = TextArea

        private void saveActionPerformed(java.awt.event.ActionEvent evt) {
         ind.setText(""); 
     
        String text = ind.getText();
     
     
            File file = new File("C:Inventory2.dat");
     
     
                 try {
                FileOutputStream out = new FileOutputStream(file, true);
     
                String textsub = (text);
     
                out.write(textsub.getBytes());
     
                out.close();
            } catch (FileNotFoundException ex) {
            } catch (IOException ioe) {
            }
     
        }

    Am i missing somthing?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,420
    Thanks
    49
    Thanked 2,215 Times in 2,188 Posts

    Default Re: Need help with write to .dat file code from textarea

    get the textArea to do the same thing:
    Please explain what the problem is. What does the code do or not do?
    What is written to the file?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    589
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Need help with write to .dat file code from textarea

    I bet nothing is written:
    ind.setText(""); 
    String text = ind.getText();

  4. #4
    Member
    Join Date
    Jan 2013
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with write to .dat file code from textarea

    PhHein thank you that fixed it. setText was erasing everything so nothing was added.

Similar Threads

  1. How to read a String .dat file into an array
    By Wallatrix in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: March 5th, 2013, 01:55 PM
  2. help with GUI .. read file and write file
    By kernal in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 14th, 2012, 10:38 AM
  3. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 05:51 PM
  4. Sorting data from a file into textarea
    By paperkut in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 26th, 2011, 07:38 AM
  5. Need help with reading from .dat file
    By cyoung in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 26th, 2011, 07:34 AM