下面的代码是在实现HTTP协议封装Response时的部分代码 
SimpleHttpResponse.java 
OutputStream ops;
PrintWriter writer;
String ce = "utf-8";
public OutputStream getOutputStream() throws Exception {
		if(dateType==W)throw new Exception("getWriter() has already been called!");
		if(ops==null){
			ops = new ByteArrayOutputStream();
			dateType = O;
		}
		return ops;
	}
public PrintWriter getWriter() throws Exception {
		if(dateType==O)throw new Exception("getOutputStream() has already been called!");
		if(writer==null){
			ops = new ByteArrayOutputStream();
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(ops,ce)),true);
			dateType = W;
		}
		return writer;
	}
W和O表示已经定义流的模式。 
为什么getWriter()之后不能getOutputStream()?或者getOutputStream()之后不能getWriter()呢?
很简单writer是写入字符的,一行写完之后还可能会插入换行回车。显然是不能和outputStream重叠使用。 
原理已经给出了,请楼主自己根据实际情况理解错误的原因。