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

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();

also what are you trying to accomplish with:
String document = in.readLine().toString();
whats with ".toString()"? it obviously already returns a String
seeing as how youve already assigned the previous readLine() to
a String variable named "f".
Are you trying to create a copy? If so you want "new String(String)"

Similar Messages

  • Mirror Door not working, dont know why??

    Hi, i turned my mac on and got the normal apple chime, but it did not boot up it just went to a blank blue screen so i waited for a while and unpluged it from the mains power, i waited then pluged it back in turned it on and nothing it wouldnt even switch on... ?? can anyone give me any ideas of what to do? Thanks.

    Hello! For starters try resetting the PMU since it was unhooked from the wall. press the button once with all external cables (a/c, monitor, usb, firewire etc.) unhooked and then try restarting. If you still get the blue screen try starting from the install disc for Tiger and run the disk repair function. Tom
    PMU location
    [IMG]http://img470.imageshack.us/img470/1623/mddlogicbd4ga.jpg[/IMG]

  • I've lost a load of notes, but dont know why or how to get them back. I cant find the folder that is in my Yahoo account that people have suggested might be the location for the messages.  I recently signed into iCloud for the first time.

    I've lost a load of notes, but dont know why or how to get them back. I cant find the folder that is in my Yahoo account that people have suggested might be the location for the messages.  I recently signed into iCloud for the first time.  Any idea how to get the notes back?   I really dont want to lose them.

    It should keep asking for the password, because it's trying to check for purchases... As soon as you login, it will see you have pending downloads and create the downloads section on the left below Purchases under the Store section. Then it will start the music downloads there, as they will be listed one below the other.
    You could just try to check your account balance or view your account and that will trigger a password request too. You can just click on that and say that now iTunes keeps asking for the password and ask him to help you with that. Trick would be to interrupt him so that he carries on with another task after, so he doesn't notice the download. Or you carry on with email or browsing which you were "busy" with when iTunes interrupted you for the password (stupid iTunes)

  • SSRS 2008 Work order Report , when added item descriotion , somehow costgroup id is not working , donot know why, ( need help)

    SSRS 2008 Production orders created report, when I added item description some how cost group id is not working ,
    my costgroup id did not break into labor , only Mat Cost showed in the total,
    my query is as below,  did I link the wrong field,   I want to show Labor total also
    can some one suggest what I did wrong .
    any advise will be great
    SELECT        PRODTABLE.PRODID, PRODCALCTRANS.COSTGROUPID, PRODTABLE.QTYCALC, PRODTABLE.PRODSTATUS, PRODCALCTRANS.COSTAMOUNT,
                             PRODCALCTRANS.COSTMARKUP, PRODCALCTRANS.REALCOSTAMOUNT, PRODCALCTRANS.CALCTYPE, PRODTABLE.DATAAREAID, PRODCALCTRANS.KEY3,
                             PRODCALCTRANS.CONSUMPVARIABLE, PRODCALCTRANS.REALCONSUMP, PRODTABLE.ITEMID, PRODTABLE.SCHEDDATE, PRODTABLE.FINISHEDDATE,
                             PRODCALCTRANS.KEY1, PRODCALCTRANS.TRANSDATE, PRODCALCTRANS.QTY, PRODCALCTRANS.KEY2, PRODCALCTRANS.COLLECTREFLEVEL,
                             PRODCALCTRANS.LINENUM, INVENTTABLE.ITEMNAME, INVENTTABLE.ITEMID AS Expr1, PRODTABLE.INVENTTRANSID
    FROM            PRODTABLE INNER JOIN
                             PRODCALCTRANS ON PRODTABLE.PRODID = PRODCALCTRANS.PRODID AND PRODTABLE.DATAAREAID = PRODCALCTRANS.DATAAREAID INNER
    JOIN
                             INVENTTABLE ON PRODCALCTRANS.DATAAREAID = INVENTTABLE.DATAAREAID AND PRODCALCTRANS.KEY1 = INVENTTABLE.ITEMID
    WHERE        (PRODTABLE.PRODSTATUS = 7) AND (PRODTABLE.DATAAREAID = N'AR1') AND (PRODTABLE.ITEMID = @itemid) AND
                             (PRODTABLE.FINISHEDDATE >= @Paramfromdate) AND (PRODTABLE.FINISHEDDATE <= @Paramtodate) AND (PRODCALCTRANS.COLLECTREFLEVEL
    = 1) AND
                             (PRODCALCTRANS.CALCTYPE >= 0)

    Hi Bitia,
    As per my understanding, after you add Item field to the report, it does not calculate total of matl group, right? If that is the case, please refer to the following steps to troubleshoot the problem:
    Modify the dataset used to retrieve data, delete the fields will not be used in the report.
    Run the query in SQL Server Management Studio (SSMS) to make sure that there is data for matl cost group.
    Make sure that row group and totals are correctly added.
    In addition, do you want to add Finished date to page header? If that is the case, we can use ReportItem to achieve the goal. Please refer to the following steps:
    In design surface, right-click the report and click Insert, then click Page Header.
    Drag Text Box from Toolbox to page header.
    Right-click inside of Text Box, then click Expression.
    In the expression text box, type the code like below:
    =ReportItems!FinishedDate.Value
    If the problem remain unresolved, please provide the screenshot of the report in design view, the following screenshot is for your reference:
    Reference:
    ReportItems Collection References
    Adding Grouping and Totals
    Thanks,
    Wendy Fu

  • Code not working, anyone know why?

    I'm making a simple pong game, and it's important to me that I use JAVA as efficient as possible (that is, use object orientated stuff, mostly). So, for drawing the ball and the players, I had thought up the following steps:
    - the applet has an array list that contains drawables*
    - if the ball and players need to be drawn, the applet uses a for-each loop, wich will call the draw(Graphics g) of all the drawables in the array list.
    * interface, guarantees that the method public void draw(Graphics g) is pressent.
    This is how I programmed it:
    http://willhostforfood.com/access.php?fileid=32821
    Only problem is, it doesn't work. The method paint() of the applet should result in "Hello World" being drawn on the screen (I know this seems like an eleborate method, but using seperate objects will help organise things once I have like, 20 - 30 balls on screen), but it doesn't.
    Does anyone know why it is not working?

    Here ya go, this is something I did quite a while ago, knock yourself out:
    package RandomColor;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.awt.Image;
    import java.awt.image.MemoryImageSource;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.awt.event.MouseWheelListener;
    import java.awt.Point;
    import java.awt.Toolkit;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.util.Random;
    public class RandomColor extends JFrame implements MouseListener, MouseMotionListener, MouseWheelListener{
      private BufferedImage myImage = null;
      private Canvas myCanvas = null;
      private Color bgColor = Color.BLACK;
      public RandomColor() throws java.lang.Exception {
        super();
        setUndecorated(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setBackground(bgColor);
        Dimension myDimension = Toolkit.getDefaultToolkit().getScreenSize();
        setSize(myDimension);
        setMinimumSize(myDimension);
        JPanel myJP = new JPanel();
        myJP.setBackground(bgColor);
        Dimension dImage = new Dimension(this.getAccessibleContext().getAccessibleComponent().getSize());
        myCanvas = new Canvas();
        myCanvas.addMouseListener(this);
        myCanvas.addMouseMotionListener(this);
        myCanvas.addMouseWheelListener(this);
        myCanvas.setSize(dImage.width, dImage.height);
        myJP.add(myCanvas);
        add(myJP);
    // start of code to hide the cursor   
        int[] pixels = new int[16 * 16];
        Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
        Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), "invisiblecursor");
        getContentPane().setCursor(transparentCursor);
    // end of code to hide cursor   
        pack();
        setVisible(true);
        Random myR = new Random();
        myImage = new BufferedImage((int) (dImage.getWidth()+0.99), (int) (dImage.getHeight()+0.99), BufferedImage.TYPE_INT_RGB);
        int i = myImage.getWidth();
        int j = myImage.getHeight();
        Ball[] myBall = {new Ball(), new Ball(), new Ball()};
        for (int k=0; k<myBall.length; k++){
          myBall[k].setBackGroundColor(Color.BLACK);
          myBall[k].setBounds(0, i, 0, j);
          myBall[k].setRandomColor(true);
          myBall[k].setLocation(myR.nextInt(i), myR.nextInt(j));
          myBall[k].setMoveRate(32, 32, 1, 1, true);
          myBall[k].setSize( 289, 167);
        Graphics g = myImage.getGraphics();
        while(true) {
          for (int k=0; k<myBall.length; k++){
            g.setColor(myBall[k].fgColor);
            g.fillOval(myBall[k].x, myBall[k].y, myBall[k].width, myBall[k].height);
          invalidate();
          paint(getGraphics());
          for (int k=0; k<myBall.length; k++){
            g.setColor(myBall[k].bgColor);
            g.fillOval(myBall[k].x, myBall[k].y, myBall[k].width, myBall[k].height);
            myBall[k].move();
      public void mouseClicked(MouseEvent e){
        exit();
      public void mouseDragged(MouseEvent e){
    //    exit();
      public void mouseEntered(MouseEvent e){
    //    exit();
      public void mouseExited(MouseEvent e){
    //    exit();
      public void mouseMoved(MouseEvent e){
    //    exit();
      public void mousePressed(MouseEvent e){
        exit();
      public void mouseReleased(MouseEvent e){
        exit();
      public void mouseWheelMoved(MouseWheelEvent e){
        exit();
      private void exit(){
        System.exit(0);
      public void paint(Graphics g){
        super.paint(g);
        myCanvas.getGraphics().drawImage(myImage, 0, 0, null);
      public static void main(String[] args) throws java.lang.Exception {
        new RandomColor();
        System.out.println("Done -- RandomColor");
    }Ball Class:
    package RandomColor;
    import java.awt.Color;
    import java.util.Random;
    public class Ball {
      private int iLeft      = 0;
      private int iRight     = 0;
      private int iTop       = 0;
      private int iBottom    = 0;
      private int moveX      = 1;
      private int moveY      = 1;
      private int xScale     = moveX;
      private int yScale     = moveY;
      private int xDirection = 1;
      private int yDirection = 1;
      private boolean moveRandom = false;
      private boolean colorRandom = false;
      private Random myRand = null;
      public Color fgColor = Color.BLACK;
      public Color bgColor = Color.BLACK;
      public int x = 0;
      public int y = 0; 
      public int width  = 1;
      public int height = 1;
      public Ball(){
        myRand = new Random();
        setRandomColor(colorRandom);
      public void move(){
        x = 5 + x + (xScale*xDirection);
        y = 5 + y + (yScale*yDirection);
        if(x<=iLeft){
          x = 0;
          if(moveRandom) xScale = myRand.nextInt(moveX);else xScale = moveX;
          xDirection *= (-1);
          if(colorRandom) setRandomColor(colorRandom);
        if(x>=iRight-width){
          x = iRight-width;
          if(moveRandom) xScale = myRand.nextInt(moveX);else xScale = moveX;
          xDirection *= (-1);
          if(colorRandom) setRandomColor(colorRandom);
        if(y<=iTop){
          y = 0;
          if(moveRandom) yScale = myRand.nextInt(moveY);else xScale = moveY;
          yDirection *= (-1);
          if(colorRandom) setRandomColor(colorRandom);
        if(y>=iBottom-height){
          y = iBottom-height;
          if(moveRandom) yScale = myRand.nextInt(moveY);else xScale = moveY;
          yDirection *= (-1);
          if(colorRandom) setRandomColor(colorRandom);
      public void setColor(Color c){
        fgColor = c;
      public void setBackGroundColor(Color c){
        bgColor = c;
      public void setBounds(int Left, int Right, int Top, int Bottom){
        iLeft   = Left;
        iRight  = Right;
        iTop    = Top;
        iBottom = Bottom;
      public void setLocation(int x, int y){
        this.x = x;
        this.y = y;
      public void setMoveRate(int xMove, int yMove, int xDir, int yDir, boolean randMove){
        moveX       = xMove;
        moveY       = yMove;
        moveRandom  = randMove;
        xDirection  = xDir;
        yDirection  = yDir;
      public void setRandomColor(boolean random){
        colorRandom = random;
        switch (myRand.nextInt(3)+1){
          case 1:  fgColor = Color.BLUE;
                   break;
          case 2:  fgColor = Color.GREEN;
                   break;
          case 3:  fgColor = Color.RED;
                   break;
          default: fgColor = Color.BLACK;
                   break;
      public void setSize(int width, int height){
        this.width  = width;
        this.height = height;
    }

  • I recently bought an iphone 5s on kijii but my rogers nanno does not work, anyone know why?

    Why doenst my iphone work?

    Assuming the seller wasn't lying, contact Rogers to try a new Nano SIM.

  • My organ pacthes arent working dont know why

    to mee it was working until i updated my logic 9to the latest update now all organ pacthes not working

    This problem can exist in Mainstage 2.x.x and Logic 9.x.x.
    Here's how you fix it.
    1) Double-click on the EVB3 plug-in (Blue box below the I/O section of your channel strip.
    2) Then click on "View" in the upper left-hand of the plug-in window.
    3) Change it from "Editor" to "Controls"
    4) Scroll down to the "General" portion (almost all the way down in that window)
    5) Under "Basic Midi Ch:" select the channel that is coming from the desired controller keyboard.
    Enjoy!
    Nathan M. - FRS Apple Store R130

  • HT201210 trying to download an instal ios 7 on my iphone 4s, after half an hour into the download it came up with a message saying failed and everytime i try again the download doesnt start. tried downloading from itunes aswel but not working. anyone know

    trying to download an instal ios 7 on my iphone 4s, after half an hour into the download it came up with a message saying failed and everytime i try again the download doesnt start. tried downloading from itunes aswel but not working. anyone know why?

    The servers are overloaded. There are a hundred million people all trying to download iOS 7 at one time. Try again later

  • The sound on my ipad 3 suddenly stopped working i dont know why i tried the last two days to fix it and also restored it and the sound never came back, please help.....

    the sound on my ipad 3 suddenly stopped working i dont know why i tried the last two days to fix it and also restored it and the sound never came back, please help.....

    Do you get sound on any apps e.g. Music and Videos but not others ? If you do then have you got notifications muted ? Only notifications (including games) get muted, so the Music and Videos apps, and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • I download the lightroom cc and it give me indication up to date but i can not open it . i dont know why , help please

    i download the lightroom cc and it give me indication up to date but i can not open it . i dont know why , help please

    Hi Wael,
    You can follow the article: Sign in, Sign out | Creative Cloud desktop app to sign out and sign in back again to Creative Cloud and try to launch your Lightroom 2015 application.
    Let us know if it works or not.
    Thanks,
    Ratandeep Arora

  • TS1424 my itunes will NOT let me buy any explicit music and i dont know why can anyone help me?

    my itunes will NOT let me buy any explicit music and i dont know why can anyone help me?

    Either:
    iTunes is trying to protect you from the ugly side of the adult world
    Your parents are trying to protect you from the ugly side of the adult world
    You've turned on the Parental/Content Restrictions by mistake
    Look in iTunes at Edit/Preferences/Parental>Content Restrictions>Restrict explicit content and make sure the tick is not in the checkbox.
    Tango1214, you are reminded

  • HT1409 I have done this but it does not work with one of my albums and I dont know why??

    I have done this but it does not work with one of my albums and I dont know why??

    That would be it. Sometimes you can tweak the album & artist names enough for iTunes to download matching art from the store, or you could add a bonus track featuring 1 second of silence and attach artwork to that, or you could convert the files to Apple Lossless.
    tt2

  • HT4097 Help! Everytime I try to update my iPad 2 on 4.3.3 it get is error message "The iPad "iPad" cannot be restored at this time because the iPad software update server could not be contacted or is temporarily unavailable." I dont know why please help

    Help! Everytime I try to update my iPad 2 on 4.3.3 it get is error message "The iPad "iPad" cannot be restored at this time because the iPad software update server could not be contacted or is temporarily unavailable." I dont know why please help.
    I'm running 4.3.3 on a ipad 2 im computer is connected via wire to internet

    See
    iOS 5: Updating your device to iOS 5
    http://support.apple.com/kb/HT4972
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect to your computer & click on the "Update your device using iTunes".
    Tip - You may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. After you update to iOS 5.x, the next update can be installed via wifi (i.e., not connected to your computer).
     Cheers, Tom

  • I can't entered in iTunes Store.not working and i dont know why

    I can't entered in iTunes Store.not working and i dont know why

    "Error 11222"
    Apple is investigating reports of this issue. Proxies, certificate issues, or your Internet service provider may be the cause of this issue.
    From:
    http://support.apple.com/kb/TS3297

  • When i sync my iphone5 on my computer with itune the last part does not stop sync download safari i dont know why is not sync and i cant stop it i am try to download some song and this thing cant stop sync help?

    when i sync my iphone5 on my computer with itune the last part does not stop sync download safari i dont know why is not stop sync and i cant stop it i am try to download some song and this thing cant stop sync help?

    Hi,
    /Users/sarahschadek/Desktop/Safari.app/Contents/MacOS/Safari
    Move the Safari app from the Desktop to the Applications folder.
    Restart your Mac.
    That's why you see this:
    When I try to do the updates my computer says it has ready it goes through like it is downloading them then at the end it says some of the files could not be saved to "/" files.
    After your restart your Mac, click the Apple  menu (top left in your screen) then click:  Software Update ...
    Carolyn  

Maybe you are looking for

  • How to print special characters?

    Hello friends, I am reading a file contains special characters like...é when i read the file, in internal table it shows as # how can i print the special characters (é) on output? Regards, RH

  • Can you change the time gap in songs with iPhone

    I really want to change the time gap in between each I my songs on my iPhone 4 but I don't know if I can or even how so if anyone can help :)

  • Movie rental download is taking to long.

    Im trying to rent a movie. It says I still have 7 hours left for it to download. But, as it downloads it asked if I would like to watch the movie now or later. When I pressed now the screen changed and the movie did not play at all. It starts to play

  • Unable to download any files no matter the browser, any ideas?

    I am unable to download any file, in chrome I got the warning that hte igetter plugin could not be loaded but in safari and firefox it just doesn't download the file. Any help would be appreciated.

  • International travel tips

    Any international travel tips for the iPhone I should know about.  I know to take the Roaming off,but anything else?