The Artima Developer Community
Sponsored Link

Java Answers Forum
File size

3 replies on 1 page. Most recent reply: Aug 23, 2003 1:26 AM by David

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Prajna

Posts: 4
Nickname: prajna
Registered: Aug, 2003

File size Posted: Aug 21, 2003 2:27 AM
Reply to this message Reply
Advertisement
Given an input stream, is it possible to determine the size of file it represents ?

Please reply soon,
Prajna


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: File size Posted: Aug 21, 2003 3:47 AM
Reply to this message Reply
I don't think it's possible.

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: File size Posted: Aug 22, 2003 9:16 AM
Reply to this message Reply
The class InputStream has a method, available() which returns the number of bytes that can be read (or skipped over) without blocking.

FileInputStream which extends InputStream has a method getChannel() which returns a FileChannel.
A FileChannel has a size() method which is the current size of the FileChannel.

David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: File size Posted: Aug 23, 2003 1:26 AM
Reply to this message Reply
...assuming no bytes have already been read...

Flat View: This topic has 3 replies on 1 page
Topic: Null Pointer Exception Previous Topic   Next Topic Topic: Custom ClassLoader & getClassLoader

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use