JAVA IO八(PrintWriter)

JAVA IO—PrintWriter

一.PrintWriter

PrintWriter用于将格式化数据写入底层Writer。

	public static void main(String[] args)  throws Exception{
		PrintWriter printWriter = new PrintWriter(System.out);

		printWriter.println(true);
		printWriter.println(123);
		printWriter.println(0.456);

		printWriter.close();
	}

二.PrintStream

PrintStream用于将格式化数据写入底层OutputStream。

public static void main(String[] args)  throws Exception{
		PrintStream  printWriter = new PrintStream (System.out);

		printWriter.println(true);
		printWriter.println(123);
		printWriter.println(0.456);

		printWriter.close();
	}

你可能感兴趣的:(java)