Results 1 to 2 of 2
  1. #1
    JorisBelier is offline Member
    Join Date
    May 2012
    Rep Power

    Default 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:
    Java Code:
    URL url = new URL(name);
    ReadableByteChannel rbc = Channels.newChannel(url.openStream());
    FileOutputStream fos = new FileOutputStream(fileName);
    fos.getChannel().transferFrom(rbc, 0, 1 << 24);

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Alternative to InputStream#read

    Moved from New to Java

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 5
    Last Post: 11-10-2011, 11:51 PM
  2. Is there an alternative to OBEX?
    By danielpereira in forum Advanced Java
    Replies: 0
    Last Post: 10-17-2010, 11:36 PM
  3. How to read multiple ZipEntry using single InputStream?
    By prasannadavid in forum New To Java
    Replies: 5
    Last Post: 09-08-2010, 01:31 PM
  4. Replies: 13
    Last Post: 09-16-2009, 01:05 PM
  5. Unable to read data from inputstream
    By renuka_anil in forum Java Servlet
    Replies: 0
    Last Post: 01-29-2009, 03:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts