bufferedinputstream

    5热度

    5回答

    假设我有一个接受InputStream的方法。 此方法需要使用BufferedInputStream封装此InputStream以使用其标记和重置功能。但是,传入的InputStream仍可能被方法的调用者使用。 public static void foo(InputStream is) throws Exception { BufferedInputStream bis = new

    0热度

    2回答

    我有一个文件,它由一个写入文件开头的序列化String对象组成,后面跟着我试图提取的文件的原始字节。 这里是我的代码: FileInputStream fileInputStream = new FileInputStream("C:\Test.tst"); ObjectInputStream objectInputStream = new ObjectInputStream(fileInput

    2热度

    1回答

    在io.BufferedReader中有方便的peek函数。但是 peek([n]) Return 1 (or n if specified) bytes from a buffer without advancing the position. Only a single read on the raw stream is done to satisfy the call. The

    0热度

    1回答

    我想实现如下: BufferedInputStream is = new BufferedInputStream(System.in); int c = 0; while((c=is.read())!=-1) Files.copy(is, path3, StandardCopyOption.REPLACE_EXISTING); Hoewver它陷在等待Sys

    3热度

    3回答

    在写的Javadoc: /** * ...Buffers the input stream so do not pass in a BufferedInputStream ... */ public static void meth(InputStream is) throws IOException { BufferedInputStream bis = new Buffered

    5热度

    2回答

    我使用Java的BufferedInputStream类读取发送到套接字的字节。 到套接字的数据是HTTP形式,因此通常是具有定义的内容长度的头,然后是一些内容。 我遇到的问题是,有时BufferedInputStream.read()不会读取发送给它的全部数据量。它返回读取的字节数,但是这比已经发送的少得多。我已经验证使用Wireshark发送的字节数和正在传输可以确认完整的消息) 下面 示例代

    1热度

    2回答

    我有一个InputStream,以及相对的文件名和大小。 我需要访问/读取InputStream中的一些随机(增加)位置。这个位置存储在一个整数数组(名为偏移量)中。 InputStream inputStream = ... String fileName = ... int fileSize = (int) ... int[] offsets = new int[]{...}; //

    0热度

    1回答

    我有一套从套接字获取数据的自反序列化类。序列化的数据格式在有效载荷之前的报头中提供长度信息。如果有效负载不可解密,我想使用上述标题中的长度信息跳过整个块。 但是,为了做到这一点,我需要知道已经从套接字读取了多少数据。我认为BufferedInputStream将允许我在使用mark()之前使用mark(),然后使用pos和markpos来确定读取的数据量,但是意识到这两个变量或受保护。 除了子分类

    0热度

    3回答

    嗨,我用下面的代码将我的对象转换为输入流。但我其实想将我的对象转换为BufferedInputStream。我应该对我的代码做些什么改变? ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos);

    1热度

    2回答

    如何确定Buffer的大小,同时使用Buffered Input Stream读取批量文件?是否基于文件大小?我正在使用, byte[] buf = new byte[4096]; 如果我增加缓冲区大小,它会快速读取?