filechannel

    3热度

    6回答

    我使用ByteBuffers和FileChannels将二进制数据写入文件。当为大文件或连续多个文件做这件事时,我会遇到一个例外情况OutOfMemoryError。 我读过其他地方,使用Bytebuffers与NIO已损坏,应该避免。你们有没有遇到这种问题,并找到一种解决方案来高效地将大量二进制数据保存在java文件中? jvm选项-XX:MaxDirectMemorySize要走的路吗?

    5热度

    6回答

    我有以下代码: String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE)