Results 1 to 3 of 3
Thread: Printing indexOf line
- 03-06-2011, 05:49 AM #1
Member
- Join Date
- Mar 2011
- Location
- Brazil
- Posts
- 2
- Rep Power
- 0
[SOLVED]Printing indexOf line
Hello,
Please could anyone help me to find a better way to print a specific line in the text.
For instance, I have a Router interface configuration:
!
interface TenGigE0/0/0/0.200
bandwidth 1000
service-policy input QOS_IN
service-policy output QOS_OUT
ipv4 address X.X.X.X 255.255.255.252
encapsulation dot1q 200
!
Using indexOf function, I know that some line is configured, now I need to print a specif line (service-policy output QOS_OUT).
How can I do that?
Thanks in advance
CLRGomesLast edited by clrgomes; 03-06-2011 at 08:14 AM. Reason: [SOLVED]
- 03-06-2011, 08:11 AM #2
Member
- Join Date
- Mar 2011
- Location
- Brazil
- Posts
- 2
- Rep Power
- 0
[SOLVED] Printing indexOf line
Hi Guys
I got a solution, I don't know if it is the best one.
String [] linha1 = result.split("\n"); //break the text in lines
for (int i=0;i<linha1.length;i++)
{
if(linha1[i].indexOf("service-policy") != -1) //Read each line looking for this string
{
String [] linha2 = linha1[i].split(" "); //If found, break line in spaces
print ("QoS "+linha2[2]+" Configurado: "+linha2[3]); //print the specific fields
}
}
It works fine, if someone have a better solution please let me know
Thanks
CLRGomesLast edited by clrgomes; 03-06-2011 at 08:16 AM. Reason: [SOLVED]
- 03-06-2011, 08:30 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
printing 3 elements in an array on 1 line
By Symbiot in forum New To JavaReplies: 2Last Post: 05-27-2010, 12:29 PM -
Having trouble with printing a blank line.
By Meta in forum New To JavaReplies: 4Last Post: 05-11-2010, 10:54 PM -
Log4j not printing out file and line number
By devin in forum Java ServletReplies: 2Last Post: 03-05-2009, 03:16 PM -
Issue with printing line
By Azndaddy in forum Advanced JavaReplies: 1Last Post: 04-04-2008, 07:37 PM -
Printing command line arguments
By Java Tip in forum Java TipReplies: 0Last Post: 12-03-2007, 09:27 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks