estou com problemas para trocar os chars especiais de um arquivo
estou abrindo o arquivo e lendo ele com stringbuffer, mas o arquivo estah cheio de pontos espaços e outros, eu naum estou conseguindo fazer com que ele troque especiais para zeros
dei uma olhada no replaceall e acho que seria ele o cod da jogada mas naum estou conseguindo implementar aqui no cod pq naum to conseguindo criar a instancia.
alguem ja passou por isso, poderiam me ajudar?
vai o codigo:
Date nom = new Date();
SimpleDateFormat formato = new SimpleDateFormat("yyyyMMdd");
String data = formato.format(nom);
File file1 = new File("ident"+ data +".nfe");
File file2 = new File(data +".rpt");
// caracter
int ch1, ch2;
// Memoria de conteudo
StringBuffer strContent1 = new StringBuffer("");
StringBuffer strContent2 = new StringBuffer("");
FileInputStream fin1= null;
FileInputStream fin2 = null;
String troca1;
troca1 = new String(strContent1);
troca1 = troca1.replaceAll("[ ]","[0]");
//Tenta abrir
try
{
fin1 = new FileInputStream(file1);
while( (ch1 = fin1.read()) != -1)
strContent1.append((char)ch1);
fin1.close();
}
catch(FileNotFoundException e)
{
System.out.println("Não acho no caminho " + file1.getAbsolutePath());
}
catch(IOException ioe)
{
System.out.println("Erro na abertura " + ioe);
}
if(file1.exists()){
System.out.println("o arquivo existe");
}else{
System.out.println("não existe este arquivo!!");
}
try
{
fin2 = new FileInputStream(file2);
while( (ch2 = fin2.read()) != -1)
strContent2.append((char)ch2);
fin2.close();
}
catch(FileNotFoundException e)
{
System.out.println("Não acho no caminho " + file2.getAbsolutePath());
}
catch(IOException ioe)
{
System.out.println("Erro na abertura " + ioe);
}if(file2.exists()){
System.out.println("o arquivo existe");
}else{
System.out.println("não existe este arquivo!!");
}
System.out.println(strContent1);
}
}
