Java.io. print stream

// print stream
	public static void main(String[] args) throws Exception {

		// Decorate the design pattern, repack the FileOutputStream to make its output easier
		PrintStream printStream =
				new PrintStream(new FileOutputStream(new File("c:" + File.separator + "T1.txt")));
		
		//The following content is directly output to the file
		printStream.print("sometime");
		printStream.println();//Interlaced
		printStream.println("test");
		//This is very familiar, just like System.out.println()
		//In fact, System.out is the object of the print stream printStream
		//So, System.out.println() is actually the method in printStream
		
		printStream.close();//Close the print stream
	}

Guess you like

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