I have a formatted text like this:
x.i9j11k2d1" index="603" value="0"/>
x.i9j11k2d2" index="604" value="0"/>
x.i9j11k2d3" index="605" value="0"/>
x.i10j1k1d1" index="606" value="-0"/>
And, I'm interested in Scanning only the digits. For example:
int i,j,k,d,index,value;
For the first line I want:
i=9, j=11, k=2, d=1, index=603, value=0
For this purpose, I used the following code:
Scanner file=new Scanner(new File("C:/sol.txt"));
while(file.hasNext())
    {           
        System.out.println("");
        int i=0;
        int j=0;
        int k=0;
        int d=0;
        file.useDelimiter("");          
        while(!(file.hasNextInt()))
        {
            System.out.print(file.next());
        }
        //System.out.print(file.next());
        file.useDelimiter("j");
        i=file.nextInt();
        System.out.print(i);
        file.useDelimiter("");
        System.out.print(file.next());      //j
        file.useDelimiter("k");
        j=file.nextInt();
        System.out.print(j);
        file.useDelimiter("");
        System.out.print(file.next());      //k
        k=file.nextInt();
        System.out.print(k);
        System.out.print(file.next());      //d
        d=file.nextInt();
        System.out.print(d);
        while(!(file.hasNextInt()))
        {
            System.out.print(file.next());
        }
        file.useDelimiter("\"");
        int index=file.nextInt();
        System.out.print(index);
        file.useDelimiter("");
        while(!(file.hasNextInt()))
        {
            System.out.print(file.next());
        }
        int value=file.nextInt();
        System.out.print(value);
        System.out.print(file.nextLine());      
    }
    file.close();
    }
    catch (FileNotFoundException exc)
    {System.out.println("File non trovato");}
It works perfectely until i is one digit, but then, when i have to scan the fourth line, I don't know why it returns the following:
...
//System.out.print(file.next());
file.useDelimiter("j");
i=file.nextInt();                   // it returns i=1 instead of 10
System.out.print(i);
file.useDelimiter("");
System.out.print(file.next());      //j    --> prints 0 instead of j
file.useDelimiter("k");
j=file.nextInt();                   //     --> finds j instead of 1 and  
                                    //         crashes with "InputTypeMismatch"
the file is formatted in XML, i cannot post the entire file cause it's thousands of lines, but it's like the following:
    <?xml version = "1.0" encoding="UTF-8" standalone="yes"?>
<CPLEXSolution version="1.2">
 <header
   problemName="prob"
   solutionName="incumbent"
   solutionIndex="-1"
   objectiveValue="58.2123812523709"
   solutionTypeValue="3"
   solutionTypeString="primal"
   solutionStatusValue="102"
   solutionStatusString="integer optimal, tolerance"
   solutionMethodString="mip"
   primalFeasible="1"
   dualFeasible="0"
   MIPNodes="3285"
   MIPIterations="22164"
   writeLevel="1"/>
   <variables>
  <variable name="x.i0j1k1d1" index="0" value="0"/>
  <variable name="x.i0j1k1d2" index="1" value="0"/>
  <variable name="x.i0j1k1d3" index="2" value="0"/>
  <variable name="x.i0j1k2d1" index="3" value="1"/>
  </variables>
  </CPLEXSolution>