Current position:  Home > Default > IndexOf problem

IndexOf problem

Time:November 30
Advertisement
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 do get problem as it gives "String index out of range: -1" error
i am trying to return the string between any ">" and "<" in the html file ,which exists in the html file,
tanks in advance
public String  viewpageBody(String newURLStr)
      try {
         URL example = new URL (newURLStr);
      BufferedReader in = new BufferedReader(
                              new InputStreamReader(
                              example.openStream()));
      String Nexthtml="";
      String inputLine="";
      int sstar=1;
      while ( ( inputLine != null ) && ( aborted == false ))
                    inputLine = in.readLine().toLowerCase();
                   if ( inputLine != null )
                                  {      System.out.println(inputLine);
                                       int star=      inputLine.indexOf( ">",sstar);
                                System.out.println(star);
                                int ref=       inputLine.indexOf("<",star);
                                 System.out.println(ref);
                                sstar=ref;
             String Bodyweb =      inputLine.substring( star,ref);
                         //     inputLine = stopWord( Bodyweb ); // do some manipulation
                         //      System.out.println(inputLine);
                                   Nexthtml += Bodyweb; // add up string
      in.close();
  return Nexthtml;   
       catch (Exception e) {
            System.out.println("File error: "+e);
     return "";                     
}
Advertisement
what are the results of your System.out.println's? If one of your index is -1 then a failure could happen...

If argument with a tiny indexOf problem

-0001-11-30

These values get through the argument: may may/jun and get separated This does not: may/jun/jul What am I doing wrong here? function Blomstring(ar){ var newAr = []; var newData = []; var findEl = false; var el = ""; for(var i=0; i<ar.length;

IndexOf problems

-0001-11-30

i have tried to implement indexOf and it doesnt seem to be displaying the results as i would like them too. i HAVE looked thru the tutorials and such, but it only gives one example, which does not suffice. i just want to do a simple swap with the fir

Problem with indexOf ()

-0001-11-30

Hi, I have a strange problem with this method. I have a some String like this: ":8547:Yog.Mora 200g:5123:0.4:0.5:123456789" ":8548:Yog.Mora 220g:5123:0.8:0.9:123456789" ":8549:Yog.Mora 250g:5123:1.0:1.2:123456789" ok now I us

Vector.indexOf(object) problem?

-0001-11-30

Hi, I'm looping thru a sql resultset with three rows and trying to match values in a column with values in a vector. Even tho the values appear to be perfect matches, I keep getting -1 on all the values. <%= vectorRank.indexOf(crsSkill.getobject("

Problems with indexOf reading from an updating string

-0001-11-30

String[][] shapeArray = new String[5][2]; int isCol; int isCom; String outputsub1 = finoutput;  // finoutput is holding text imported from a file String outputsub2; for (int y = 0; y < 2; y++)      for (int x = 0; x < 5; x++)           isCol = outpu

Imsadmin user purge problem ??

2015-10-11

"Hi, I am having a prob with purging users of one particular domain ..... Though I can purge users of all other domains fine !!! I am running ims5.2 hf 2.07 The errors I get are : admin-serv/logs/error ==================== [22/Sep/2005:10:23:54] fail

ArrayList problem ....i can remove my object from my arrayList

2015-10-11

hi all, i am going to remove a object from my array by using arrayList.However, it can`t work properly and did nth for me..i don`t know why...could anyone give me some suggestion and show me what i did wrong on my code ....i stated more detail next t

Unknown problem with JSP, JavaScript - Pls help

2015-10-11

Hi Friends, I am facing a strange problem. Explained it below. Kindly help me as it is really affecting my work. Thanks in advance. I am working on building a web application using jsp, servlet, ejb. the IDE used is WSAD 5.1.2. I have the below : 1 J

Help with add file name problem with Photoshop CS4

2015-10-11

Frustrating problem: Help with add file name problem with Photoshop CS4. What happens is this. When I am in PS CS4 or CS3 and run the following script it runs fine. When I am in Bridge and go to tools/photoshop/batch and run the same script it runs u

Problem Sending mails in a loop using JavaMail API

2015-10-11

Hello All, I am sending emails in a loop(one after the other) using JavaMail API,but the problem is, if the first two,three email addresses in the loop are Valid it sends the Email Properly, but if the Fourth or so is Invalid Address it throws an Exc

NullPointer exception in request.getParameter().indexof(.....) only in 6.1

2015-10-11

Hi I have one full working application (containing WAR + JAR) files. Right now this application is working absolutely fine in weblogic 6.0 sp1 on WINNT & Solaris. In this application, we accept events to save data from external applications like exce

Problem with socket communications

2015-10-11

I am trying to put together a client server socket communication pair. I have one application that runs in the background acting as a server and another that can be started and stopped that acts as a client. I can start the server and create a server

Problems with the Proxy Programme--Please help

2015-10-11

Hi All, I have written a simple proxy server in the form of a servlet. I changed the proxy config of my browser to connect to this servlet hosted on the default context(http://localhost:8080) of the Tomcat 5.0.25 . Well , this servlet internally conn

Problems creating a sticky footer

2015-10-11

Hi, I'm trying to create a website in Dreamweaver using a template that I purchased but I am having problems fixing a footer to the bottom of the page, At the moment the content footer that I have created (which is a table) changes positon from page

Spry Menu Bar Horizontal Problem in Internet Explorer

2015-10-11

I'm having a problem with a spry menu bar. It works fine in Firefox and Google Chrome, but in Internet Explorer the submenus shift to the right. And here's the code: @charset "UTF-8";/* SpryMenuBarHorizontal.css - version 0.6 - Spry Pre-Release

Problems parsing double quote

2015-10-11

I have been trying to figure out my problem for several hours, but still didn't get it. Hope to get an idea from you guys. My code is as follows: var astr; var outCr ="|"; var outLf = "\u0000"; var cr = "\n"; var lf ="\r

OBIEE Report using webservices : problem using the htmlviewservice.

2015-10-11

Hi, I have a requirement that i have to display OBIEE report on web browser. i followed the following article for achieving this. http://oraclebizint.wordpress.com/2007/07/31/customizing-obi-ee-soap-api/. I have a problem while creation of the html p

Problem in getting data on button submit

2015-10-11

I have 3 combo boxes in a form & a button on the other html form when the user will change the combo box, the form will be submitted with the values of all three combo boxes. And when the button is pressed it will again submit the form along with all

Problem in Bluetooth client program

2015-10-11

Hello, i'm developing a J2ME application. It runs over a mobile phone with Bluetooth and it should connect with an BT Adapter. Mobile phone rol is client, and the adapter is the server. I have a problem because when mobile phone executes the method p