Going, nuts 2 printwriters?

B

bigbinc

Can you call 2 printwriters in a function(main) because on the first
call of printwriter, everything is fine, on the second call I get a
compile error, java.io not found.


// no error

// get a handle to the output stream
PrintWriter out = new PrintWriter(System.out);

String _sWidth = "480";
String _sHeight = "365";




String _fname = e__mainHTML + "i_" + sewershed + _PipeID + ".html";

Writer _tmp = java.io.FileWriter(_fname);

PrintWriter newout = PrintWriter(_tmp);


I get an error above.
 
J

Joona I Palaste

bigbinc said:
Can you call 2 printwriters in a function(main) because on the first
call of printwriter, everything is fine, on the second call I get a
compile error, java.io not found.
// no error
// get a handle to the output stream
PrintWriter out = new PrintWriter(System.out);
String _sWidth = "480";
String _sHeight = "365";
String _fname = e__mainHTML + "i_" + sewershed + _PipeID + ".html";
Writer _tmp = java.io.FileWriter(_fname);
PrintWriter newout = PrintWriter(_tmp);

Maybe you mean "new PrintWriter(_tmp)" instead of "PrintWriter(_tmp)"
here?
I get an error above.

This may help you correct some error, but I don't know if that's the
error you're talking about.
 
J

Jared Dykstra

Can you call 2 printwriters in a function(main) because on the first
call of printwriter, everything is fine, on the second call I get a
compile error, java.io not found.


// no error

// get a handle to the output stream
PrintWriter out = new PrintWriter(System.out);

String _sWidth = "480";
String _sHeight = "365";




String _fname = e__mainHTML + "i_" + sewershed + _PipeID + ".html";

Writer _tmp = java.io.FileWriter(_fname);

PrintWriter newout = PrintWriter(_tmp);


I get an error above.


The compiler is looking to call a static function called FileWriter
which doesn't exist. Change to

Writer _tmp = new java.io.FileWriter(_fname);

to actually create an object. The same problems exists on the
following line, you want to create a PrintWriter object, not call a
function called PrintWriter on a writer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top