缓冲输出流写出数据的缓冲区问题

public class BufferedOutputStream_flush {
		
	public static void main(String[] args) throws IOException {
		FileOutputStream fos=new FileOutputStream("fos.txt");
		 
	    BufferedOutputStream bos=new BufferedOutputStream(fos);
		String str="让我再看你一遍,从南到北123132";
		
		byte[] data=str.getBytes();//转换字节数组
		bos.write(data);
		/*
		 * void flush()
		 * 一次性将缓冲区中的数据写出
		 */
		bos.flush();//提高及时性
		System.out.println("写出完毕");
		//bos.close();//里面有flush方法
	}
}

你可能感兴趣的:(android)