This content has been marked as final. Show 9 replies
I'm more amazed that the OS allows it, I had no clue there was such a possibility in Windows.
I still wouldn't know why you would ever want to write low level to a disc though, and I wonder if the OS would allow that. Even if it does, I wonder if the rights of the user are sufficient to allow it. It seems like something that can really cause some damage.
EJP wrote:There must be a terminology problem in that response or in this thread.
There's no way Windows or any sane operating system will allow you write access to a raw drive while there are mounted filesystems on it.
I am fairly certain that every modern desktop OS provides "raw" (also called "direct") access to file systems - even when in use. Without it I would suppose that it would be impossible to write certain tools/drivers/etc.
This isn't of course suggesting that it is a good idea or even one that is likely to succeed unless one is very, very careful. And I doubt it is possible in Java.
Following references which seem to suggest that raw access is possible. And I didn't see anything that suggested that it couldn't happen while the device was in use.
I suppose I should have clarified that point: I am trying to use block devices without any file systems. As a comparison, I was able to try out this code on a Linux distro yesterday, and when I ran as root, it seemed to work on a ramdisk without a mounted fs:
RandomAccessFile file = new RandomAccessFile("/dev/ram2","rw");
ByteBuffer buf = ByteBuffer.allocateDirect(512);
Again, the question is why I can't do something similar in Windows, even when I run as administrator, and even when I can open a block device for read in Java.
I am trying to use block devices without any file systems. As a comparison, I was able to try out this code on a Linux distro yesterday, and when I ran as root, it seemed to work on a ramdisk without a mounted fs:This entire line is contradictory.The ramdisk may not have a filesystem itself, but /dev/ram2 most definitely IS mounted into a filesystem. And because it is you have easy access to it because Linux makes that possible.
Windows on the other hand is not Linux. You can't throw Java at this problem and then automagically have a cross-platform way of accessing OS specific resources. The answer to your query should likely be found in a Windows programming forum and may just require the use of native code, if it is at all possible to do on Windows.