Click to See Complete Forum and Search --> : File Output
Crazy_bee
Aug 21st, 2001, 12:48 PM
I am assigning text from an edit box to a string variable and trying to output then string to a text file. I the file created but there are some symbols and a "null" and the end of the line. This is the code I used:
try
{
ostream = new DataOutputStream(new FileOutputStream("temp.dat"));
ostream.writeUTF(stCombinedRecord);
ostream.close();
}
catch(IOException e)
{
System.exit(1);
}
Any help is awesome!!!!!!
;)
Dillinger4
Aug 22nd, 2001, 01:43 PM
Pretty good! From what i have read about Swing though
Graphical components do not make good candidates for IO
(even though im not to familiar with the edit box
unless you mean JTextArea) because a stream is an ordered sequence of bytes of an undetermined length. Given a group
of bytes provided as data, there must be a fixed order to those bytes for them to be read of written as a stream. However a
user can change the contents of a text area of a text field at any point, not just the end. Furthermore, they can delete data from the middle of a stream while another thread is reading is reading that data.
You can however always use the strings they produce to create a byte array input stream or a string reader
Crazy_bee
Aug 22nd, 2001, 03:38 PM
I am using the Edit control in visual j++.
Dillinger4
Aug 22nd, 2001, 03:44 PM
Ahhhh ok. Im not familar with Microsofts version of Java.
You should switch to Sun's Java. From what i remember when i was in school they dropped J++ from their course because Microsoft was being sued for ripping off Sun. So i think Visual J++ was discontinued. but im not sure.
Dillinger4
Aug 22nd, 2001, 03:53 PM
Leave the dark side of Microsoft young Jedi..... and see the light
of the Sun. :p
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.