java - How to get small part of a command output -


After this post I want to get a Linux installation date.

  process p = runtime.gettime (). Exec ("rpm -qi basesystem");  

Can you tell me how I can execute the command and capture only the installation date as shown in the post.

I have to get the full output and filter the content and the final result using Java should be something like this:

  Thursday 28 November 2013 06:01: 06 PM EST  

Read the input stream and parse it:

  process proc = Runtime.getRuntime (). Exec ("rpm -qi basesystem"); InputStream stdin = proc.getInputStream (); InputStreamReader isr = New InputStreamReader (stdin); Buffed reader br = new buffed reader (ISR); String line = null; Date Date = Zero while ((line = br.readline ())! = Null) {// Check each line for the date you need // set date // break; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -