-3

Possible Duplicate:
Is it possible to format a memory stick, pen drive or disk using Java?

I need to format my pendrive into NTFS file system using a Java program. Can you please tell me how can I do this? Thank you

Community
  • 1
  • 1

2 Answers2

4

Run native command line utilty of OS you are using. For example format c: on Windows :)

Use either Runtime.getRuntime().exec() or ProcessBuilder for this. Disk formating is a responsibility of file system that strongly depends on platform. Java is a cross-platform and I doubt it has (and even can or should have) such built-in functionality unless somebody already created library that wraps platform specific calls I mentioned and provides pure java API.

AlexR
  • 114,158
  • 16
  • 130
  • 208
1

you can not format directly. You will need to invoke a operating system specific program to do the actual work for you. check this link this might help you

Community
  • 1
  • 1
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
  • 1
    +1 Under unix, as root, you can read/write the raw disk. If you know the exact format for an NTFS drive it could be done in theory, but it would take an obscene amount of effort. – Peter Lawrey Jun 06 '12 at 09:25