> Indeed yes,
> 1 ) Put your program's output into a varibale
> 2 ) Write this variable's value to the output
> stream.
>
> Simple ehh...
To the OP.
Ignore everyting from samue-1 . He know very little and is wrong about 95% of the time.
> Indeed yes,
> 1 ) Put your program's output into a varibale
> 2 ) Write this variable's value to the output
> stream.
>
> Simple ehh...
Mert, you should stop answering questions here. Your answers are almost always wrong. You're not helping anybody. You're just a nuisance.
> > Indeed yes,
> > 1 ) Put your program's output into a varibale
> > 2 ) Write this variable's value to the output
> > stream.
> >
> > Simple ehh...
>
>
> Mert, you should stop answering questions here. Your
> answers are almost always wrong. You're not helping
> anybody. You're just a nuisance.
Heeeey, what is wrong in here ? I think no where .
> > > Indeed yes,
> > > 1 ) Put your program's output into a varibale
> > > 2 ) Write this variable's value to the output
> > > stream.
> > >
> > > Simple ehh...
> >
> >
> > Mert, you should stop answering questions here.
> Your
> > answers are almost always wrong. You're not
> helping
> > anybody. You're just a nuisance.
>
> Heeeey, what is wrong in here ? I think no where .
Your answer was completely useless.
> > > > Indeed yes,
> > > > 1 ) Put your program's output into a varibale
> > > > 2 ) Write this variable's value to the output
> > > > stream.
> > > >
> > > > Simple ehh...
> > >
> > >
> > > Mert, you should stop answering questions here.
> > Your
> > > answers are almost always wrong. You're not
> > helping
> > > anybody. You're just a nuisance.
> >
> > Heeeey, what is wrong in here ? I think no where
> .
>
>
> Your answer was completely useless.
demonstrate it .
> If what you mean by writing the output to file is
> writing the things that you write to console to a
> file then just redirect the System.out to a
> PrintStream which is created from a FileOutputStream
This is exactly what I need to do, I just don't understand the coding. The tutorial is pretty vague. Could anyone do a simple example?
jjmclell
Example:
import java.io.*;
public class Foo {
public static void main(String[] args) throws Exception {
String path = System.getProperty("java.io.tmpdir");
String filename = path + "helloWorld.txt";
System.out.println("Using file: " + filename);
File file = new File(filename);
FileOutputStream fos = new FileOutputStream(file);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.out.println("Hello, World!");
}
}
Another option (depending on your OS)...
java -cp . YourClass > somefile.txt
~
> > If what you mean by writing the output to file is
> > writing the things that you write to console to a
> > file then just redirect the System.out to a
> > PrintStream which is created from a
> FileOutputStream
>
> This is exactly what I need to do, I just don't
> understand the coding. The tutorial is pretty vague.
> Could anyone do a simple example?
>
> jjmclell
please get the following book:
Core Java Fundamentals-1
and read starting from page 650. there are examples.
> > Heeeey, what is wrong in here ? I think no where
> .
>
> Mert, i did not understand your input either.
> i am sure you are willing to help though.
> thanks
He may be willing, but he's unable.
His Java knowledge is abysmall, as are his communication skills. He adds a net negative value to these forums.
> Example:
> import java.io.*;
>
> public class Foo {
> public static void main(String[] args) throws
> Exception {
> String path =
> System.getProperty("java.io.tmpdir");
> String filename = path + "helloWorld.txt";
> System.out.println("Using file: " + filename);
> File file = new File(filename);
> FileOutputStream fos = new FileOutputStream(file);
> PrintStream ps = new PrintStream(fos);
> System.setOut(ps);
> System.out.println("Hello, World!");
>
>
> Another option (depending on your OS)...
> java -cp . YourClass > somefile.txt
>
> ~
Thanks a lot yawmark, that was very helpful. One question though. Is there anyway to redirect the path that java writes out to? i.e. other than the temporary files in docs and settings?
Also, thanks geoman. I need all the solid reference books I can get my hands on.
jjmclell
> Thanks a lot yawmark, that was very helpful. One
> question though. Is there anyway to redirect the
> path that java writes out to? i.e. other than the
> temporary files in docs and settings?
Certainly. You can specify any path you want.
[url=http://java.sun.com/docs/books/tutorial/essential/io/]The Java Tutorial - I/O: Reading and Writing (but no 'rithmetic)[/url]
Best of luck!
~