Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » I cant redirect the output to a file
I cant redirect the output to a file [message #1168944] Sun, 03 November 2013 17:50 Go to next message
Borja Molina Zea is currently offline Borja Molina Zea
Messages: 2
Registered: November 2013
Junior Member
Hi, I configure eclipse in order to the output of the console goes to a text file

Run Configurations -> Common -> Standar Input and Output --> select the box 'file'

but It doesnt works Sad the output file is always blank
Re: I cant redirect the output to a file [message #1171202 is a reply to message #1168944] Tue, 05 November 2013 04:41 Go to previous messageGo to next message
shankha banerjee is currently offline shankha banerjee
Messages: 29
Registered: February 2013
Junior Member
Hi,
I was able to direct the output of a hello word application to a file.

Are you running the program as Java application or eclipse application.
Try running it as eclipse java application.

Thanks
Re: I cant redirect the output to a file [message #1178052 is a reply to message #1168944] Sat, 09 November 2013 10:53 Go to previous message
Arnav Kumar is currently offline Arnav Kumar
Messages: 16
Registered: October 2013
Junior Member
Try this to print output file
import java.io.FileNotFoundException;
import java.io.PrintStream;

public class SOPinTxtFile {	
private void writeFile(){		
System.out.println("hello ji from method");
}
	
public static void main(String[] args) {
try {
System.setOut(new PrintStream("c:\\output.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println("From main");
new SOPinTxtFile().writeFile();
int a=10,b=10;		
System.out.println("Division is "+a/b);
}
}

You may use log4j for this puropose.
TechKnowHeights


[Updated on: Sat, 09 November 2013 10:56]

Report message to a moderator

Previous Topic:Servise
Next Topic:Why is Javadoc view always blank? How to read Java API in Eclipse?
Goto Forum:
  


Current Time: Tue Sep 23 04:37:39 GMT 2014

Powered by FUDForum. Page generated in 0.01903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software