Results 1 to 4 of 4
  1. #1
    hunter2379 is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Quick! Writing to text file.

    Hello, so I'm trying to write to a text file. Each time I run the program any previous data in the text file gets deleted.
    Everything was declared above. Currently fileName input is "x" without quotes
    Java Code:
    		fileName = JOptionPane.showInputDialog("Please Input File Name with .txt extension: ");
    		filex = new File(fileName+".txt");
    		
    		BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filex));
    		
    		if(filex.exists()){x=1; System.out.println("aaaaaaa");}
    		if(!filex.exists() && filex.getName()!=null && filex.getName()!=""){filex.createNewFile();JOptionPane.showMessageDialog(null, "File Didn't exist. File Created!");}
    		if(filex.getName()==""){System.exit(0);}

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default Re: Quick! Writing to text file.

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    hunter2379 is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Re: Quick! Writing to text file.

    WELL...I feel stupid! Thanks a lot!!!! adding ,true solved it.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default Re: Quick! Writing to text file.

    You're welcome. You can't know every method signature in the API docs :)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Replies: 8
    Last Post: 07-17-2011, 02:38 PM
  2. Writing Text To A File
    By loopsnhoops in forum New To Java
    Replies: 15
    Last Post: 06-01-2011, 03:27 AM
  3. Writing into a text file
    By africanhacker in forum New To Java
    Replies: 3
    Last Post: 03-31-2011, 10:44 PM
  4. Replies: 1
    Last Post: 02-27-2010, 01:29 AM
  5. writing text to file
    By notwist in forum New To Java
    Replies: 3
    Last Post: 04-25-2008, 04:20 AM

Posting Permissions

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