Java and streams...

Orsorum

Lifer
Dec 26, 2001
27,631
5
81
'K, I'm doing this for a class project... we have to display some non-European characters on a GWindow, then output the hex values for that to a text file. Having trouble figuring out to implement a character stream output to a file. I understand the concept of using a stream to write something... I'm having trouble figuring out how to invoke a new Writer interface... and how to output it specifically to a file.

Any suggestions?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,464
4,305
75
I don't feel like looking this up, but I'd guess something like:

Writer f;
f.open(filename,...)

Maybe?

This is why I still use C/C++, printf, and scanf. :)
 

Orsorum

Lifer
Dec 26, 2001
27,631
5
81


<< I don't feel like looking this up, but I'd guess something like:

Writer f;
f.open(filename,...)

Maybe?

This is why I still use C/C++, printf, and scanf. :)
>>



lol Thanks for the input, nonetheless. I'll give that a try... *sigh*
 

manly

Lifer
Jan 25, 2000
12,491
3,322
136
Why guess when you can look it up in the JavaDocs.

I'm pretty sure you want to use a FileWriter. If you need details, you can look up the online Java Tutorial or Bruce Eckel's Thinking in Java.
 

Orsorum

Lifer
Dec 26, 2001
27,631
5
81


<< Why guess when you can look it up in the JavaDocs.

I'm pretty sure you want to use a FileWriter. If you need details, you can look up the online Java Tutorial or Bruce Eckel's Thinking in Java.
>>



Cool. Thank you! I've already browsed the Javadocs (I'm not THAT lazy), just wanted some clarification.
 

AmigaMan

Diamond Member
Oct 12, 1999
3,644
1
0
open an OutputStream using a File object in the constructor
create a new PrintWriter object using the OutputStream object in it's constructor
Use the println() method of the PrintWriter object.

If you're having problems using standard Java I/O, I'd suggest getting a good beginners book and read up on it.