Skip to main content



      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 12:50 Go to next message
Eclipse UserFriend
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] Mon, 04 November 2013 23:41 Go to previous messageGo to next message
Eclipse UserFriend
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 05:53 Go to previous message
Eclipse UserFriend
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 05:56] by Moderator

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


Current Time: Fri Apr 25 01:32:36 EDT 2025

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

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

Back to the top