5 Replies Latest reply: May 16, 2007 2:46 PM by 807606 RSS

    Help, Substring not working, dont know why...

    807606
      I need to load some xml file and extract some data from it.
      I have this code.
      I thing that this have to work but havent...it prints input error...
      Any suggestion?
      file is opened by this code it works

      /////
      if (e.getSource() == openButton) {
      int returnVal = fc.showOpenDialog(FileChooserDemo.this);

      if (returnVal == JFileChooser.APPROVE_OPTION) {
      file = fc.getSelectedFile();
      ////


      /// this doesnt work
      try {
      String f;
      FileInputStream fstream = new FileInputStream(file);
      BufferedReader in = new BufferedReader(new inputStreamReader(fstream));

      while ((f = in.readLine()) != null)
      {
      System.out.println(in.readLine());
      String document = in.readLine().toString();
      String startTag = "<Text>";
      String endTag = "</Text>";
      int start = document.indexOf(startTag) + startTag.length();
      int end = document.indexOf(endTag) + 1;
      String result = document.substring(start,end);
      System.err.println(result);

      }
      in.close();