Results 1 to 5 of 5
  1. #1
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question Write to external file from textfield

    I need to get user input from a Jtextfield, store it in a variable, and then write it to an external file.
    I have tried FileWriter fw = new FileWriter();, and fw.write();, but I cannot find a way to use a variable in fw.write(need to put variable here)??
    PLEASE HELP!!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Write to external file from textfield

    No don't call the write(...) method of FileWriter as that is way too low-level. Instead you need to wrap your FileWriter in another more friendly Writer such as a PrintWriter. Then you could simply call print(...) or println(...) passing in the String you wish to output.

  3. #3
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: Write to external file from textfield

    Thank you, I will try it that way!!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Write to external file from textfield

    Great and good luck. Please let us know how it turns out!

  5. #5
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: Write to external file from textfield

    I will, as soon as I can get that to work for me!!

Similar Threads

  1. Replies: 5
    Last Post: 03-10-2012, 04:46 PM
  2. Open external file with external program
    By Wietse de Vries in forum New To Java
    Replies: 1
    Last Post: 12-31-2011, 04:52 PM
  3. Make the TextField unable to write on
    By Josep_16 in forum Java Applets
    Replies: 4
    Last Post: 08-21-2011, 08:06 AM
  4. Replies: 3
    Last Post: 07-06-2011, 12:50 PM
  5. called external program does not automatically write file
    By nickvandewiele in forum New To Java
    Replies: 6
    Last Post: 02-25-2010, 02:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •