Home arrow static arrow Java Programming [Archive] - reading from file
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - reading from file
This topic has 1 reply on 1 page.

Posts:37
Registered: 6/10/04
reading from file  
Jul 6, 2004 3:56 AM



 
Hi guys,
I did use this code to read the html file and it work fine but when i try to add the restriction to it
(indexOf) i get a problem as i run the program "String index out of range: -1" error
i am trying to return the string between any ">" and "<"";
String inputLine="";
int sstar=1;
while ( ( inputLine != null ) && ( aborted == false ))
{
inputLine = in.readLine().toLowerCase();
if ( inputLine != null )
{int star= inputLine.indexOf( ">",starr);
int ref= inputLine.indexOf("<"File error: "+e);

}
return "";

}
[/code]

 

Posts:6,147
Registered: 11/9/00
Re: reading from file  
Jul 6, 2004 4:03 AM (reply 1 of 1)



 
indexOf returns -1 if it doesn't find the character you're after. You need to test for it after you've done the indexOf to determine when you've run out of tags.
 
This topic has 1 reply on 1 page.