Java里面标准IO和NIO有什么不同
2个回答
展开全部
IO是面向字节流方法(Stream Oriented),相对于NIO的面向缓冲形方法(Buffer oriented),IO没有缓存,你可以同时读取多个字节,但读取代码不能向前后移动。缓冲形方法可以让代码缓冲一段时间,这样代码更有弹性。
Java NIO's buffer oriented approach is slightly different. Data is read into a buffer from which
it is later processed. You can move forth and back in the buffer as you need to. This gives you
a bit more flexibility during processing. However, you also need to check if the buffer contains
all the data you need in order to fully process it. And, you need to make sure that when reading
more data into the buffer, you do not overwrite data in the buffer you have not yet processed.
Java NIO's buffer oriented approach is slightly different. Data is read into a buffer from which
it is later processed. You can move forth and back in the buffer as you need to. This gives you
a bit more flexibility during processing. However, you also need to check if the buffer contains
all the data you need in order to fully process it. And, you need to make sure that when reading
more data into the buffer, you do not overwrite data in the buffer you have not yet processed.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询