ARTICLE AD BOX
I'm trying to write over a section of my W drive at a certain offset with a custom array of bytes, like an automated hex editor of sorts. So far I have this:
try { URI uri = new URI("file:///W:/"); FileChannel channel = FileChannel.open(Path.of(uri), StandardOpenOption.READ, StandardOpenOption.WRITE); MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_WRITE, 4206944, 6); byte[] write = new byte[] {0x2F, 0x10, 0x50, 0xDA, 0x00, 0x10}; buff.put(write); buff.force(); } catch (IOException e) { throw new RuntimeException(e); } catch (URISyntaxException e) { throw new RuntimeException(e); }When I run this code, I get "java.nio.file.NoSuchFileException: W:\" on the line instantiating the FileChannel, presumably because the W drive isn't actually a file. Is there a way to manipulate the drive as if all of its data were the contents of a single file to achieve my goal? If there isn't a way to do this in Java, is there a way to do this in any other language? Thank you :)
