Write stream to file using NIO and channel system

I have an inputStream and I want to write it to a file.

I saw NIO and FileChannel that have the "transferTo" ou "transferFrom" method, and I know how to create a WriteableChannel, but I don't know how to convert my input stream to ReadableChannel.

Thank.

+3
source share
1 answer

Look at the method Channels.newChannel(java.io.InputStream).

newChannel

public static ReadableByteChannel   newChannel (InputStream in)
Creates a channel that reads bytes from a given stream.

;   - .   .

: - ,
:

+5

Source: https://habr.com/ru/post/1746375/


All Articles