Results 1 to 4 of 4
Thread: FileChannel
- 10-28-2010, 08:46 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 67
- Rep Power
- 0
FileChannel
I am learning about the FileChannel class.
My code using the FileChannel is:
I am really confused as to what the benefits are of using the FileChannel class as opposed to using:Java Code:String data = "friends.txt"; FileInputStream inData = new FileInputStream(data); FileChannel inChannel = inData.getChannel(); long inSize = inChannel.size(); ByteBuffer source = ByteBuffer.allocate((int) inSize); inChannel.read(source, 0); source.position(0); System.out.println("Original byte data: "); for (int i = 0; source.remaining() > 0; i++) { System.out.print(source.get()); }
FileInputStream and BufferedInputStream classes ?
I might be missing something really obvious.
Thank you
- 10-29-2010, 06:32 AM #2
Member
- Join Date
- Aug 2010
- Posts
- 67
- Rep Power
- 0
anyone?.........
- 10-29-2010, 06:37 AM #3
It's faster.
Sincerely, Joshua Green
Please REP if I help :)
- 10-29-2010, 06:38 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 67
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks