输出:将内容输出到屏幕

package com.wyq.file;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public class TestOutP {
	public static void main(String[] args) throws IOException {
//		OutputStream os = new FileOutputStream("d:\\b.txt");
		OutputStream os = System.out;
		os.write('a');
		System.out.println();
		os.write(97);
		System.out.println();
		os.write("helloworld".getBytes());
		System.out.println();
		System.out.write("apple".getBytes());
		os.close();
		
		PrintStream ps = System.out;
		ps.println("\n");
		ps.println("hello");
		ps.println(true);
		ps.write(97);
		//ps相当于System.out的意思,可以等量替换
		System.out.println("\t");
		System.out.println("hello");
		ps.close();			
		
	}
}

 

你可能感兴趣的:(Java部分知识)