Skip to content

Instantly share code, notes, and snippets.

/foo.java Secret

Created July 19, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c34268fec37aa438536ff374e6217375 to your computer and use it in GitHub Desktop.
Save anonymous/c34268fec37aa438536ff374e6217375 to your computer and use it in GitHub Desktop.
test needed?
@Override
public long executeAndparseOutput(String [] args) {
// TODO Auto-generated method stub
long duration = 0L;
try {
String output = this.processExecutor.command(args)
.readOutput(true).execute().outputUTF8();
try( Scanner scanner = new Scanner(output) ){
scanner.useDelimiter("\n");
while(scanner.hasNext()){
String data = scanner.nextLine();
Pattern pattern = Pattern.compile("Duration: (?<duration>[^,]+)");
Matcher matcher = pattern.matcher(data);
if ( matcher.find()){
System.out.println(matcher.group("duration"));
duration = this.dateFormatter.parse("1970-01-01 " + matcher.group("duration")).getTime();
break;
}
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch(TimeoutException | InterruptedException | IOException ex){
ex.printStackTrace();
}
return duration;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment