Alternative to InputStream#read
The NIO api contains some very neat possibilities. Methods that saves input streams as files to a hard drive via channels and files that are loaded directly from the hard drive into the RAM. There's however no neat solution I could find that loads input streams directly into the RAM. The only solution I could think of is looping trough the input stream. That's why I was wondering if there was an alternative to looping trough an input stream.
Some of the solutions I appreciate:
Code:
URL url = new URL(name);
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
FileOutputStream fos = new FileOutputStream(fileName);
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
Re: Alternative to InputStream#read
Moved from New to Java
db