• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Defragmentation / File Position

 
Lambert Stein
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to access a file in Java directly?
I want to change its position on the disk like a defragmenting application.
If not, is there any free external dll or exe which does this?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure there's no way to do this using pure Java, at least. No idea what existing DLLs or EXE's might be most useful to you here, sorry.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not possible with pure Java. What you want to do is get low-level access to the file system. Different operating systems use very different file systems (Windows: FAT, NTFS; Linux: ext2, ext3, reiserfs, ..., etc.) and all these file systems store data on disk in a different way.

If you want to write a defragmenting program for a specific OS and a specific file system, you'll need to know a lot about the details of that file system, and what the most efficient way is to lay out files on disk for that particular file system. It will not be a trivial program to write.
 
Saverio Miroddi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NT Systems have APIs for defragementing files!

Look at this page:

http://www.microsoft.com/technet/sysinternals/information/diskdefragmenting.mspx

however, i think using JNI would be quite a pain in the ***!

Bye!
Saverio M.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic