How to mount a drive in RAM in Java

南楼画角 提交于 2019-12-12 06:37:11

问题


I'm trying to code a RAMDisk, but I don't know how to mount a drive in RAM. I'm going to be writing this in Java. But could anyone point me to the way of making the disk in RAM with a letter and name.

Thanks!

EDIT: For clarification, I want to make a file with virtual files like stored in RAM. DataRam's Ramdisk is a good example of what I want to do. It creates a file and mounts a drive. The drive is in RAM and it writes to the file. How can I achieve this? (I wanted to create a RAMDisk for my own project with extended ideas)


回答1:


RAMDisk (as well as any other virtual device) requires a device driver to be used. Luckily, device drivers are not written in Java or C# (especially Xamarin, which is for mobile OS that don't allow virtual disks at all). While you can use Java for business logic, some part of your project would need to be written in unmanaged language, and the project itself should include a device driver. No need to say, that device drivers are different for each operating system.

Now, the virtual disks can be of several kinds - the one where you have an image formatted to certain filesystem and handle block-level requests, and the one where you handle filesystem requests and implement the file system on its own.

We have products for both cases (CallbackDisk and Callback File System respectively). They both have samples for creating a virtual disk, but only Callback File System includes Java API to use. Both products are for Windows.

On Linux there exists FUSE to implement various filesystems, on OSX there exists OSXFUSE, a port of FUSE.



来源:https://stackoverflow.com/questions/36706602/how-to-mount-a-drive-in-ram-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!