• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading and Writing to a sector on a harddrive or floppy

 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Does Java allow for this? I don't want to do a byte for byte copy per-se. I want to seek to a sector, read the data at that sector and maybe change it.
Thanks
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be able to use RandomAccessFile or FileChannel. They have the seek-read-and-maybe change-without-recopying-everything functionality you describe. However I don't know if there's a way to specify a particular sector - can this be represented by a file name (and thus a File object)? This may be too OS-specific. You might need to use JNI to connect to a C function to do this. Sorry I don't have more info offhand.
 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those wont work, Java simply wont allow me to create a FileOuputStream, RandomAccessFile object with the paramaters of A:\\
i.e.
File f = new File("\\\\.\\A:")
RandomAccessFile file = new RandomAccessFile(f, "rw");
A IO exception is thrown.
java.io.IOException: The parameter is incorrect
at java.io.RandomAccessFile.writeBytes(Native Method)
I hate to say this, but it's little quirks like this that gives C and C++ programmers reasons to look down at Java
Oh well, this app just lost the ability to claim 100% Java. Which really upsets me.
[ April 10, 2003: Message edited by: Bill May Jr ]
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill May Jr:

I hate to say this, but it's little quirks like this that gives C and C++ programmers reasons to look down at Java
[ April 10, 2003: Message edited by: Bill May Jr ]

And I have one word for them - Pointers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!