Java,流不更新?

Java,流不更新?,java,android,stream,inputstream,outputstream,Java,Android,Stream,Inputstream,Outputstream,我正在尝试使用此库连接到终端仿真器。这将连接到串行设备,并应显示通过另一个库发送/接收的用于串行通信的数据。要连接到终端会话,我需要根据文档向setTermIn(inputStream)提供inputStream,向setterout(outputStream)提供outputStream。但是,我使用串行库而不是流发送和接收字节数组,因此我需要使用ByteArrayInputStream将数据转换为流。我初始化并附加一些流,就像这样,这些只是初始流,没有附加到我想要发送/接收的数据 priva

我正在尝试使用此库连接到终端仿真器。这将连接到串行设备,并应显示通过另一个库发送/接收的用于串行通信的数据。要连接到终端会话,我需要根据文档向
setTermIn(inputStream)
提供
inputStream
,向
setterout(outputStream)
提供
outputStream
。但是,我使用串行库而不是流发送和接收字节数组,因此我需要使用
ByteArrayInputStream
将数据转换为流。我初始化并附加一些流,就像这样,这些只是初始流,没有附加到我想要发送/接收的数据

private OutputStream bos;
private InputStream bis;

...

byte[] a = new byte[4096];
bis = new ByteArrayInputStream(a);
bos = new ByteArrayOutputStream();
session.setTermIn(bis);
session.setTermOut(bos);
/* Attach the TermSession to the EmulatorView. */
mEmulatorView.attachSession(session);
除了inputstream的原始值之外,我似乎根本无法在终端会话上显示任何内容。写不起作用

问题出现在这里,尽管我可以初始化并将流设置为终端仿真器输入,但它们永远不会得到更新。因此,在下面,终端将在其中写入hello,不会写入任何其他内容,我既不能使用streams附带的write函数,也不能使用库附带的重写write函数,不会出现任何内容。如果我在
setTermIn(bis)
之后更改bis的值,如果我向bos写入的内容也不会出现在屏幕上,则不会反映任何内容

TermSession session = new TermSession();

        byte[] a = new byte[]{'h','e', 'l', 'l', 'o'};
        bis = new ByteArrayInputStream(a);
        bos = new ByteArrayOutputStream();
        session.write("test one");
        session.setTermIn(bis);
        session.setTermOut(bos);
        session.write("test two");

        /* Attach the TermSession to the EmulatorView. */
        mEmulatorView.attachSession(session);
        mSession = session;
        try {
            bos.write(a);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        session.write("test three");
重写写方法通常由库开发人员用于将信息附加到终端

write

public void write(byte[] data,
                  int offset,
                  int count)
Write data to the terminal output. The written data will be consumed by the emulation client as input.
write itself runs on the main thread. The default implementation writes the data into a     circular buffer and signals the writer thread to copy it from there to the OutputStream.

Subclasses may override this method to modify the output before writing it to the stream, but implementations in derived classes should call through to this method to do the actual writing.

你认为可能是因为我对图书馆的设置不正确吗?

你在写完文章后关闭了流吗?我会努力改进它。我没有做任何事情来关闭我能看到的溪流。我只是将它们设置为输入/输出,然后它们就永远无法更改。不幸的是,关闭流没有任何作用。我开始认为初始化和库有问题。我无法知道我是否正确设置了这些流。但它确实读取了初始值。