⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pipedwriter.java

📁 kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的java包。
💻 JAVA
字号:
/* * Java core library component. * * Copyright (c) 1997, 1998 *      Transvirtual Technologies, Inc.  All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */package java.io;import kaffe.io.CircularBuffer;public class PipedWriter extends Writer {  CircularBuffer buffer;  public PipedWriter() {  }  public PipedWriter(PipedReader reader) throws IOException {    connect(reader);  }  private void checkIfStillOpen() throws IOException {    if (buffer.isClosed()) {      throw new IOException("Pipe closed");    }  }  private void checkIfConnected() throws IOException {    synchronized(this) {      if (!isConnected()) {	throw new IOException("Pipe not connected");      }    }  }  public void connect(PipedReader reader) throws IOException {    synchronized(this) {      /* connect using the reader to avoid racing conditions. */      reader.connect(this);    }  }  private boolean isConnected() {    return buffer != null;  }  public void write(int c) throws IOException {    super.write(c);  }  public void write(char cbuf[], int off, int len) throws IOException {    checkIfConnected();    synchronized(buffer) {      while(len > 0) {	checkIfStillOpen();	if (buffer.isFull()) {	  try {	    buffer.wait();	  }	  catch (InterruptedException e) {	    continue;	  }	}	else {	  int written = buffer.write(cbuf, off, len);	  off += written;	  len -= written;	  buffer.notify(); // notify the reader.	}      }    }  }  public void flush() throws IOException {    if (isConnected()) {      synchronized(buffer) {	checkIfStillOpen();	buffer.notify();      }    }  }  public void close() throws IOException {    synchronized(buffer) {      buffer.close();      buffer.notifyAll(); // notify reader and writer.    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -