aspose file tools*
The moose likes Java in General and the fly likes Don't know how to start Defragger programming with Java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Don Watch "Don New topic
Author

Don't know how to start Defragger programming with Java.

David Sangber-Dery
Greenhorn

Joined: Nov 10, 2010
Posts: 2
I need help,ASAP, on how to start programming a Defragger in Java.
Any help is appreciated.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18988
    
  40


Please explain what you mean by a defragger.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
And welcome to JavaRanch
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

David Sangber-Dery wrote:I need help,ASAP,

Please EaseUp


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
David Sangber-Dery
Greenhorn

Joined: Nov 10, 2010
Posts: 2
Henry Wong wrote:
Please explain what you mean by a defragger.

Henry

An application that defragments a hard disk.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
I thought that is what it means. Without pointers to memory locations, is that possible at all?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18988
    
  40

David Sangber-Dery wrote:
Henry Wong wrote:Please explain what you mean by a defragger.

An application that defragments a hard disk.


First of all, Java doesn't provide an API that allows you to do direct sector reads and writes to the hard disk, so you should seriously consider using something else. You can access the OS libraries that does this via JNI, or you can access the /dev devices that allow you such access -- but again, it is probably much easier to just use C/C++, which can directly access these libraries.

And you have other issues...

1. "fragments" and hence, "defragging" is format specific. There is a world of difference between UFS, NTFS, FAT, and the tons of hard disk formats out there. Some has more fragging issues that others; some will actually defrag automatically with usage; some are actually designed well with some fragging; etc. etc. You defragger will behave differently with all of these hard disk formats.

2. The FS may actually be using the disk while you are defragging it (if the disk is mounted), so you need to make sure that you don't crash the file system driver, and hence the OS while you are doing this. To compound this, if the data is important, it wouild be a good idea to not test it on that drive first. This complexity increasing again, if you are trying to defrag the disk which your OS booted from.

Regardless, good luck...

Henry

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Not to mention that a garbage collected, densely multithreaded language like Java is very poorly suited for something as time-critical as low-level disk manipulation!


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Don't know how to start Defragger programming with Java.