aspose file tools*
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
Author

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

import java.io.*;

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

System.setOut(ps);

// do some output

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

ps.close();
}
}
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Did you check the file?

Moving to JIG (beginner) forum.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
kofi ofei
Ranch Hand

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

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: http://aspose.com/file-tools
 
subject: redirect demo 1