在Linux / Java / Scala中枚举附加的DVD驱动器 [英] Enumerating attached DVD drives in Linux / Java / Scala

查看:144
本文介绍了在Linux / Java / Scala中枚举附加的DVD驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Scala(在Java上运行)应用程序我想得到包含DVD媒体的所有驱动器的列表,例如类似这样的事情:

In my Scala (runs on top of Java) Application I would like to get a list of all drives that contain DVD media, e.g. something like this:


  • / dev / scd0 Star Trek DS9 DVD1

  • / dev / scd0 4400 DVD1

不确定是否可以获得光盘的名称,但无论如何,路径对我来说都很重要。

Not sure if it's possible to get the name of the disc, but the path is the important thing for me anyway.

我更喜欢纯Java / Scala解决方案(使用file.io的东西)。如果这不可能,那么访问正确的Linux文件也很好(比如/ proc / something)。

I would prefer a pure Java / Scala solution (using file.io stuff). If that's not possible, accessing the right Linux files is fine, too (like /proc/something).

提前致谢!

推荐答案

我认为你对java.io. *运气不好但是如果你不介意调用Linux命令,你可以通过以下方式组装数据:

I think you're out of luck with java.io.* but if you don't mind making calls out to Linux commands, you could assemble the data by:


  1. 调用mount并捕获第一列输出。

  2. 调用volname从步骤1中捕获的每个值。

根据volname的手册页,它只返回ISO-9660文件系统的数据(例如DVD),因此任何返回空的设备路径都可以忽略。

According to the man page for volname, it only returns data for ISO-9660 filesystems (e.g. DVDs), so any device path that returns empty can be ignored.

这篇关于在Linux / Java / Scala中枚举附加的DVD驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆