Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

parsing the end of lines in std output

Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I have the following scenario where by I am want to parse the last few lines in a std output and find not the very last occurence of an integer value but the sceond occurence

the stdout has the followng last few lines that i am interested in

The stdout is the console ...

blah blah blah above which also has loads of numeric values ...

C:\HOME\abc\Test>Connection closed by foreign host.

The code i have to retrieve the value 0 in the third line is

Any ideas why the below is not returning the value 0 ???

int ReturnTheSecondLastThatHasTheEndOfLineInteger(String output) {
String[] words = output.split("[\n]");
for (int i = words.length-3; i-- > 0;) {
try {

Integer num = Integer.parseInt(words[i].trim());
return num;
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Garden Master Course kickstarter
    Bookmark Topic Watch Topic
  • New Topic