Results 1 to 4 of 4
  1. #1
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Arrow problem facing with StringSelection to save into txt file

    hi,

    i have a TextField in myGUI where some data(results) are shown after calculation. I have a 'save' button to save this result into a particular txt file..

    i almost done without error....but inside my txt file it shows this kind of things:
    java.awt.datatransfer.StringSelection@157f0dc
    Please anybody help me to figure out.................

    here is the code:
    Java Code:
     else if (e.getSource()==saveButton){
     
     int x=Integer.parseInt(inputField.getText());
     String str=Integer.toString(x*x);
     resultField.setText(str)  
      
           try {
    	
    // String selection =selection.getSelectedText();
      String selection=resultField.getText();
      StringSelection data= new StringSelection(selection);
      
    File outFile= new File("c:/Java/math.txt");
    FileOutputStream fos=new FileOutputStream(outFile);
    PrintWriter pr=new PrintWriter(fos);
    
    pr.print(data);
    pr.close();}
    
    catch (IOException ioe) {	
         ioe.printStackTrace();
         System.exit(0);}

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

  3. #3
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Default

    oh.. ya

    thanks a lot... actually i m just editing from book... so couldn't think the simply way...

    anyway thanks again.

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

Similar Threads

  1. save file based on file extension
    By masa in forum AWT / Swing
    Replies: 4
    Last Post: 05-11-2010, 11:17 AM
  2. Facing problem in making connection to mail server
    By Basit56 in forum New To Java
    Replies: 2
    Last Post: 01-22-2010, 06:27 PM
  3. i am facing some problem with <h:selectOneMenu> default One
    By sridharavulapati in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 09-09-2009, 02:08 PM
  4. Facing problem while sending e-mail
    By jay8186 in forum Java Servlet
    Replies: 1
    Last Post: 03-25-2009, 07:34 AM
  5. how to save file..
    By jont717 in forum New To Java
    Replies: 2
    Last Post: 02-12-2009, 11: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
  •