• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Available space for file on server

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

A server accepts files from a client. The files could be any size. The client can communicate the file's size to the server before starting the transfer which is fine. What I am trying to achieve is to be able to respond to the client whether or not there is enough space on the server to store that file before the transfer begins.

The issue of course is that Java has no way to ascertain the free space on a given filesystem. I cannot go native because the application must be platform independant so I need to find a Java only solution.

Does anyone have any ideas?

My first thought is to write out a temp file of the size of the client file and then if that doesnt error, accept the transfer but this seems like a very poor solution to what should be a simple problem...

Thanks in advance.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this via google: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4057701
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you - I should have googled. I will wait until 6 then.

J Wenting has commented in there - I wonder if it is the same one that comes here.
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ooooh - I missed the last comment - apparently Apache Commons can do this. Thanks Ilja
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that JDK 6 Beta is available now, and the methods you want are in the File class: getFreeSpace() and getUsableSpace().
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But no matter how you get the free space, if at some instant ten thread all see a meg free, they can't all write a meg file. Clients should still be prepared for disappointment now and then.
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic