Results 1 to 4 of 4
  1. #1
    maitoti is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default Java.lang.ArrayIndexOutOfBoundsException:0>=0

    hello,ihad tihs error when i run my project ; the error appear in this level on my script
    Java Code:
    public void doQRPatient() { 
         System.out.println("methode patien dcm"); 
            String cmd = ""; 
            MyParser parser = new MyParser(); 
            Vector total1 = new Vector(); 
            Vector total2 = new Vector(); 
            Vector total3 = new Vector(); 
            try { 
                cmd = userDir + BIN_DCMQR + java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("_-R_00080090_-R_00100010_-R_00100020_-R_00081030_") + " " + aeTitle + "@" + address + ":" + port; 
                System.out.println("COMANDO 1:" + cmd); 
                total1 = executer(cmd); 
                for (int i = 0; i < total1.size(); i++) { 
                    System.out.println(i+".-\t"+(String)total1.elementAt(i)); 
                } 
                System.out.println("app comb vec-ref"); 
                combineVectors1_referring_2(1, parser.parsePatient(total1.toArray()), parser.parseStudyUID(total1.toArray()), parser.parseNumberSeries(total1.toArray()), parser.parseNumberImages(total1.toArray()), parser.parseReferring(total1.toArray()), parser.parseStudyDesc(total1.toArray())); 
                parent.showMessage(java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("INICIADA_COMUNICACION_DICOM_CON_EL_NODO:_") + " "+aeTitle + "@" + address + ":" + port); 
            
           
            } catch (Exception err) { 
                err.printStackTrace(); 
                //parent.showMessage(java.util.ResourceBundle.getBundle("com/jjcp/resources/Strings").getString("HAOCURRIDOUNERROR")+aeTitle+"@"+address+":"+port); 
                parent.showMessage("ERROR :" + aeTitle + "@" + address + ":" + port); 
            } 
        }
    and the error appear in this method exsactely in while boucle

    Java Code:
    private Vector executer(String cmd) { 
      Vector result = new Vector(); 
      try { 
                        System.out.println("method executer"); 
       Process p = Runtime.getRuntime().exec(cmd); 
       BufferedReader input = new BufferedReader(new InputStreamReader(p 
         .getInputStream())); 
       String line; 
       while ((line = input.readLine()) != null) 
        {result.addElement(line); 
                            System.out.println("line"); 
       }
    input.close(); 
      } catch (Exception ex) { 
       ex.printStackTrace(); 
      } 
      return result; 
     }
    because whene i run it in dont see the word "line" in my output
    so if any one have an idea,please tell me .
    beast regards .

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    If the process p has no endline terminators, then when it closes, line will be null, and so 'result' will be zero length. The 'toArray" commands in doQRPatient will result in arrays of zero length. I'm guessing that 'MyParser' is not properly handling the degenerate case of zero length arrays.

  3. #3
    maitoti is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    so i tyr to read the first element of an empty vector ;how can i resolved it??
    and am sure that there is no problem with myparser:which the code is

    public class MyParser {

    MyParser() {
    }

    public Vector parseStudyUID(Object array[]) {
    Vector data = new Vector();
    System.out.println("parse study id");
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0020,000D)"))) { //$NON-NLS-1$
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parseSeriesUID(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0020,000E)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }
    public Vector parseStudyDesc(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,1030)"))) { //$NON-NLS-1$
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    if(token.contains(java.util.ResourceBundle.getBund le("pacs/resources/Strings").getString("STUDY_DESCRIPTION")))
    token=java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("--");
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }
    public Vector parseSerieDesc(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,103E)"))) { //$NON-NLS-1$
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    if(token.contains(java.util.ResourceBundle.getBund le("pacs/resources/Strings").getString("SERIES_DESCRIPTION")))
    token=java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("--");
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }
    public Vector parseNumberSeries(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0020,1206)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parseNumberImages(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0020,1208)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parsePatient(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0010,0010)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }
    public Vector parseReferring(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,0090)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }

    }

    return data;
    }
    public Vector parseImages(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,0018)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp,java.util.ResourceBundle.getB undle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parseSeriesDescription(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,0018)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parseSeriesImagesCount(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0020,1209)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public Vector parseSeriesModality(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0008,0060)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println(token);
    }
    }

    return data;
    }

    public static void main(String args1[]) {
    }


    public Vector parsePatientName(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0010,0010)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println("Patient Name detectado: "+token);
    }
    }

    return data;
    }
    public Vector parsePatientID(Object array[]) {
    Vector data = new Vector();
    for(int i = 0; i < array.length; i++) {
    String temp = (String)array[i];
    if(temp.startsWith(java.util.ResourceBundle.getBun dle("pacs/resources/Strings").getString("(0010,0020)"))){
    //System.out.println(temp);
    StringTokenizer tokenizer = new StringTokenizer(temp, java.util.ResourceBundle.getBundle("pacs/resources/Strings").getString("[]"));
    String token = tokenizer.nextToken();
    //System.out.println(token);
    token = tokenizer.nextToken();
    data.addElement(token);
    //System.out.println("Patient ID detectado: "+token);
    }
    }

    return data;
    }

    }
    i think the problem is in execute method so can i resolve it
    Last edited by maitoti; 04-01-2011 at 11:26 AM.

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Before trying to access the elements of a Vector, call the 'size' method to verify that the Vector has enough elements. A zero length Vector is perfectly valid and ordinary. You can't simply assume it has elements in it.

Similar Threads

  1. Java.lang.ArrayIndexOutOfBoundsException
    By Ladyjest1 in forum New To Java
    Replies: 1
    Last Post: 07-12-2010, 10:11 PM
  2. java.lang.ArrayIndexOutOfBoundsException: 6
    By pyat77 in forum Java Applets
    Replies: 6
    Last Post: 03-06-2010, 01:12 PM
  3. java.lang.ArrayIndexOutOfBoundsException
    By mensa in forum Java 2D
    Replies: 7
    Last Post: 05-05-2008, 09:09 AM
  4. java.lang.ArrayIndexOutOfBoundsException
    By mew in forum New To Java
    Replies: 2
    Last Post: 12-02-2007, 09:40 PM
  5. java.lang.ArrayIndexOutOfBoundsException
    By Marcus in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 05:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •