title: Is there a way to get file size having only FileDescriptor?
body: <p>Let's assume that I have a valid Java <code>FileDescriptor</code> which I got in this way:</p>
  
  <pre><code>FileInputStream is = new FileInputStream("/some/path/to/file.txt");
  FileDescriptor fd = is.getFD();
  </code></pre>
  
  <p>Now please forget that I know file path. The only thing I have is a <code>FileDescriptor</code>. Is there a <strong>simple way</strong> to know the file size?
  For now I've checked that:</p>
  
  <ol>
  <li><code>FileDescriptor</code> has <code>valid()</code> method which can tell me if it's valid
  but doesn't have <code>length()</code> or <code>size()</code> functionality.</li>
  <li><code>FileInputStream</code> doesn't return the path and since it's a stream it
  obviously won't tell me the file size.</li>
  <li><code>File</code> (<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/java/io/File.html</a>)
  which has <code>length()</code> method doesn't have a constructor able to handle
  FileDescriptor.</li>
  </ol>
  
  <p>I know that I could read whole stream and sum the length but I don't consider it as <strong>simple way</strong>.</p>