Olá a todos. Criei o método abaixo:
public static String lerCopiarString(File arquivo) throws IOException {
BufferedReader input=null;
String str = null;
try{
int BUF_SIZE = (new Long(arquivo.length())).intValue();
input = new BufferedReader(new FileReader(arquivo));
int numRead = 0;
char[] buf = new char[BUF_SIZE];
numRead = input.read(buf);
str = new String(buf, 0, numRead);
}finally{
if(input!=null)
input.close();
}
return str;
}
e em raros casos o numRead está sendo setado com o valor -1 dando a seguinte exceção:
2009-01-26 04:32:19,830 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException in method: public abstract boolean br.inf.portalfiscal.nfe.controller.UtilLocal.recepcionarNFe(java.io.File) throws java.text.ParseException,br.inf.portalfiscal.nfe.exception.NfeAplicacaoException,java.io.IOException:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
Eu copio vários arquivos por dia e os mesmos são apagados logo depois. Eu gostaria de saber em quais casos isso está ocorrendo já q eu não tenho acesso aos arquivos depois de copiados.
Muito obrigada.