Java.io. Output redirection

// output redirection
	// Let the contents of System.out.println() be output to the hard disk file
	public static void main(String[] args) throws Exception {

		System.setOut(new PrintStream(new FileOutputStream(new File("d:" + File.separator + "T1.txt"))));
		System.out.println("just a test");
		System.out.println("1234qwer");
	}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327039607&siteId=291194637