File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes redirect demo 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "redirect demo 1" Watch "redirect demo 1" New topic

redirect demo 1

kofi ofei
Ranch Hand

Joined: May 22, 2005
Posts: 39
when i compile the programme there are no errors but when i run it nothing appears to be happening


public class RedirectDemo1{
public static void main(String args[]) throws IOException {

// set up a PrintStream pointing at a file

FileOutputStream fos =
new FileOutputStream("out.txt");
BufferedOutputStream bos =
new BufferedOutputStream(fos, 1024);
PrintStream ps =
new PrintStream(bos, false);

// redirect System.out to it


// do some output

System.out.println("This is a test\u4321");
int n = 37;
System.out.println("The square of " + n + " is " + (n * n));

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Did you check the file?

Moving to JIG (beginner) forum.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
kofi ofei
Ranch Hand

Joined: May 22, 2005
Posts: 39
Marco Davids II

Joined: Nov 02, 2004
Posts: 24
i ran your code as is and it seemed to work fine ...
what errors are you getting ?
I agree. Here's the link:
subject: redirect demo 1
It's not a secret anymore!