java - Something going wrong with the charAt method? -


this part of program giving me trouble. file getting received program. without charat method program runs perfectly. i'm not sure issue is. not program in entirety, part giving me error.

the error:

java.lang.stringindexoutofboundsexception: string index out of range: 0 @ java.lang.string.charat(unknown source) @ genseq.main(genseq.java:111) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ edu.rice.cs.drjava.model.compiler.javaccompiler.runcommand(javaccompiler.java:272)

program:

do{    line = inputstream.nextline();    line = line.trim();     if (line.charat(0) == '>'){    //checking see if it's information line    info = info + line;    count++;    //used count number of entries    }    else{      seq = seq + line;      //concatenating sequence    }  while (inputstream.hasnextline());  inputstream.close(); 

edit: we're dealing dna , rna sequences letter can start either a, t, c, g, or u. handle blank lines tried now. still getting error though.

do{        line = inputstream.nextline();        char first = line.charat(0);         if (first == '>'){        //checking see if it's information line        info = info + line;        count++;        //used count number of entries        }         if (first == 'a' || first == 't' || first == 'g' || first == 'c' || first == 'u'){          seq = seq + line;        }      }      while (inputstream.hasnextline());      inputstream.close(); 

possible solution replace line.charat(0) == '>' line.startswith (">") @ least removes problem arrays , can finish debugging there.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -