Results 1 to 4 of 4
- 01-30-2010, 07:16 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
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:
Please anybody help me to figure out.................java.awt.datatransfer.StringSelection@157f0dc
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);}
-
Why are you using a StringSelection object here? Why not just write the String to the file?
- 01-30-2010, 07:46 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
oh.. ya
thanks a lot... actually i m just editing from book... so couldn't think the simply way...
anyway thanks again.
-
Similar Threads
-
save file based on file extension
By masa in forum AWT / SwingReplies: 4Last Post: 05-11-2010, 11:17 AM -
Facing problem in making connection to mail server
By Basit56 in forum New To JavaReplies: 2Last Post: 01-22-2010, 06:27 PM -
i am facing some problem with <h:selectOneMenu> default One
By sridharavulapati in forum JavaServer Faces (JSF)Replies: 1Last Post: 09-09-2009, 02:08 PM -
Facing problem while sending e-mail
By jay8186 in forum Java ServletReplies: 1Last Post: 03-25-2009, 07:34 AM -
how to save file..
By jont717 in forum New To JavaReplies: 2Last Post: 02-12-2009, 11:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks