Writing text to a file.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Writing text to a file.

Threaded View

  1. #1
    Join Date
    Sep 2005
    Location
    Texas.
    Posts
    8

    Writing text to a file.

    I've tried:
    Code:
                    connPort = port.getText();
                    serverIP = server.getText();
                    configF.setVisible(false);
                    try
                    {
                        BufferedWriter w = new BufferedWriter(new FileWriter(new File("sys/conf.txt")));
                        w.write(server.getText().concat("\n"));
                        w.write(port.getText());
                        w.write("This works!");
                        configL.setText("Save successful.");
                    }
                    catch(Throwable t)
                    {
                        configL.setText("Save unsucessful.");
                    }
    Where server and port are JTextAreas holding the server and port, and configL is the label for the window. The label's set to "Save Successful.", but the file is blank after this runs. Can someone please tell me why?
    EDIT 2: Above problem has been fixed. w.close(); Heh.

    EDIT: configF is the JFrame holding all of this, and it should dissappear when I call configF.setVisible(false); but it doesn't. How should I go about making it dissappear?
    Last edited by freeone3000; 10-20-2005 at 06:55 PM. Reason: Fixed first problem.

Similar Threads

  1. Transferring Text File
    By Mark in forum Database
    Replies: 0
    Last Post: 07-03-2001, 11:00 AM
  2. Formatting text and writing to it to a file
    By Matt Lake in forum VB Classic
    Replies: 0
    Last Post: 03-13-2001, 08:10 PM
  3. open text file using shell
    By Hian Chew in forum VB Classic
    Replies: 0
    Last Post: 03-06-2001, 12:28 PM
  4. Problem: Reading text file with comma
    By Paolo in forum VB Classic
    Replies: 3
    Last Post: 01-08-2001, 08:59 AM
  5. Replies: 0
    Last Post: 04-17-2000, 01:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center