解析游标输出java [英] Parse cursor output java

查看:429
本文介绍了解析游标输出java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何解析来自一个linux光标程序的输出,例如在java中顶?
我想让一个人给一个例子或链接一个。现在我得到了顶级运行像一个Process对象。 btw top只是这样一个程序的一个例子。

How can i parse the output from a linux cursor program like e.g top in java? I would like someone to give an example or link one. Right now i got top running like a Process object. And btw top is just an example of such a program.

String[] args={"top"};
Process process = new ProcessBuilder(args).start();


推荐答案

使用 curses 编写的程序不输出像典型命令行程序的字符流,甚至不使用退格技巧。相反,它使用操作系统特定的调用,如 ioctl 和特定于实现的转义序列,如 TermInfo 。通常,Unix系统上的这些程序是执行所有必要工作的库的简单前端,而你最好的选择通常是使用这些库(如果没有JNI包装则写入JNI包装)。

You can't. A program written using curses isn't outputting a stream of characters like a typical command-line program, or even one using the backspace trick. Instead, it's using operating-system specific calls like ioctl and implementation-specific escape sequences like those described in TermInfo. Generally, such programs on Unix systems are simple frontends to libraries that perform all of the necessary work, and your best option is usually to use those libraries (writing a JNI wrapper if one isn't available).

top 的情况下,您可以看到程序如何从操作系统的源代码中读取过程信息,作为< a href =http://procps.sourceforge.net =nofollow> procps软件包。

In the case of top, you can see how the program reads the process information from the OS in its source code, available as part of the procps package.

这篇关于解析游标输出java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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