Results 1 to 3 of 3
- 06-14-2010, 09:57 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
textfield - printstream - text file - to much text
Hi!
I using PrintStream and when i stored a text in at text field i got a lot of text.
Java Code:try { // Open an output stream fout = new FileOutputStream ("c:/test.txt"); // Print a line of text PrintStream p = new PrintStream(fout); p.println (path); //<<<<------ alot of text from textfield p.println (username); p.println (password); p.println (port); p.println ("test2"); //<<<<--------- work fine in text file // Close our output stream fout.close(); } // Catches any error conditions catch (IOException e) { System.err.println ("Unable to write to file"); System.exit(-1); }
The output in text file look like this
Java Code:java.awt.TextField[textfield0,10,10,380x23,text=Path,editable,selection=0-0] java.awt.TextField[textfield1,10,43,380x23,text=Username,editable,selection=0-0] java.awt.TextField[textfield2,10,76,380x23,text=Password,editable,selection=0-0] java.awt.TextField[textfield3,10,109,380x23,text=Port,editable,selection=0-0] test2
How can the java code only write the text for textfield to file? not everything? You can see println"test2" work.
thanks!
- 06-14-2010, 10:04 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You are probably printing out the textfields themselves instead of the text in the textfields.
Use the getText() method of JTextField to get the text.
- 06-14-2010, 10:18 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
How can I save the content of textfield in a text file?
By fred in forum Java AppletsReplies: 7Last Post: 08-17-2010, 06:00 PM -
Insert text records from text file into a DB
By nicedad in forum JDBCReplies: 8Last Post: 11-06-2009, 06:52 AM -
accessing the text of textfield of one class in another
By vasavi.singh in forum Advanced JavaReplies: 3Last Post: 04-05-2009, 02:54 PM -
find and replace text from a text file
By gezzel in forum New To JavaReplies: 2Last Post: 09-19-2008, 04:04 PM -
Append text inputed in the textfield into a TextArea
By romina in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 05:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks