Java "No space left on device" but there is enough space on disk?
<p>I'm trying to write files to the file system in a java programme but it fails with an exception throwing 'No space left on device' when df -h (and df -i) says otherwise. </p>

<p>Here is the output of df -h: </p>

<pre><code>Filesystem      Size  Used Avail Use% Mounted on
udev            5.9G  4.0K  5.9G   1% /dev
tmpfs           1.2G  1.4M  1.2G   1% /run
/dev/sda5       156G  139G  9.1G  94% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            5.9G  105M  5.8G   2% /run/shm
none            100M   28K  100M   1% /run/user
/dev/sda2       105G  102G  2.7G  98% /media/sam/System 
/dev/sda3       176G  163G   14G  93% /media/sam/Sam //where I'm trying to write
</code></pre>

<p>and here is the output of df -i: </p>

<pre><code>Filesystem       Inodes    IUsed    IFree IUse% Mounted on
udev            1523763      552  1523211    1% /dev
tmpfs           1526458      584  1525874    1% /run
/dev/sda5      10362880  4750381  5612499   46% /
none            1526458        2  1526456    1% /sys/fs/cgroup
none            1526458        3  1526455    1% /run/lock
none            1526458      191  1526267    1% /run/shm
none            1526458       26  1526432    1% /run/user
/dev/sda2       3832820  1045155  2787665   28% /media/sam/System 
/dev/sda3      35769712 22090147 13679565   62% /media/sam/Sam //where I'm trying to write
</code></pre>

<p>I am trying to write files to /media/sam/Sam/. I have tried restarting my machine, unmounting and mounting again but no luck. Also in Java if I create a new file object inside /media/sam/Sam and print the usage information, it prints 0 as below:</p>

<pre><code>File tweetFile = new File( "/media/sam/Sam/" + "test"  + ".txt" );
System.out.println( tweetFile.getTotalSpace()  ); // prints 0
System.out.println( tweetFile.getFreeSpace()/1000000000 ); // prints 0
System.out.println( tweetFile.getUsableSpace()/1000000000 ); // prints 0
</code></pre>

<p>Any help is really appreciated as I'm trying to fix this for the whole day and getting really frustrated. </p>

<p><strong>EDIT</strong>
Here is the exact message thrown:</p>

<pre><code>Exception: java.io.IOException: No space left on device
java.io.IOException: No space left on device
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1006)
    at utils.FileUtil.writeToFile(FileUtil.java:64)
    at experiments.usinglists.tagbasedeval.ToindexTweetsForAUser.main(ToindexTweetsForAUser.java:36)
</code></pre>