Arquivo de Remessa CNAB
bug#9100 bug#9803 bug#10881 dev:rafael.henrique qua:Marcelo git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/GeneradorBoletosCNAB/trunk@81983 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
24ca21417e
commit
46dd13bea1
|
@ -26,6 +26,7 @@ public class ArquivoRemessaBancoBrasil extends ArquivoRemessaItem {
|
|||
if(((CabecalhoRemessaBancoBrasil) cabecalhoRemessa).getCabecalhoLoteRemessaBancoBrasil() != null){
|
||||
qteRegistroArq++;
|
||||
qteRegistroLote++;
|
||||
loteCount++;
|
||||
}else{
|
||||
throw new RuntimeException("Falta cabecalho tipo: " + CabecalhoRemessaBancoBrasil.class.getName());
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.rjconsultores.ventaboletos.layouts;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
@ -106,8 +112,9 @@ public abstract class AbstractFlatFile{
|
|||
|
||||
try {
|
||||
|
||||
in = ClassLoaders.getResourceAsStream(cfgFile.getPath(), this.getClass());
|
||||
|
||||
//in = ClassLoaders.getResourceAsStream(cfgFile.getPath(), this.getClass());
|
||||
in = getClass().getResourceAsStream(cfgFile.getPath());
|
||||
|
||||
File config = File.createTempFile(cfgFile.getTemp(), null);
|
||||
|
||||
copyInputStreamToFile(in, config);
|
||||
|
@ -139,16 +146,29 @@ public abstract class AbstractFlatFile{
|
|||
|
||||
public void copyInputStreamToFile(InputStream initialStream, File targetFile) throws IOException {
|
||||
|
||||
OutputStream outStream = new FileOutputStream(targetFile);
|
||||
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
// OutputStream outStream = new FileOutputStream(targetFile);
|
||||
//
|
||||
// byte[] buffer = new byte[8 * 1024];
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = initialStream.read(buffer)) != -1) {
|
||||
// outStream.write(buffer, 0, bytesRead);
|
||||
// }
|
||||
//
|
||||
// IOUtils.closeQuietly(initialStream);
|
||||
// IOUtils.closeQuietly(outStream);
|
||||
|
||||
Reader reader = new BufferedReader(new InputStreamReader(initialStream));
|
||||
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(targetFile), "Cp1252"));
|
||||
|
||||
char[] buffer = new char[8 * 1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = initialStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, bytesRead);
|
||||
while ((bytesRead = reader.read(buffer)) != -1){
|
||||
writer.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
IOUtils.closeQuietly(initialStream);
|
||||
IOUtils.closeQuietly(outStream);
|
||||
IOUtils.closeQuietly(reader);
|
||||
IOUtils.closeQuietly(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,7 +317,8 @@ public abstract class AbstractFlatFile{
|
|||
"Arquivo TXT a ser importado nulo!"));
|
||||
}
|
||||
|
||||
FileUtils.writeLines(arquivoRemessaFisico, this.lines, "\r\n");
|
||||
FileUtils.writeLines(arquivoRemessaFisico, "Cp1252", this.lines, "\r\n");
|
||||
//FileUtils.writeLines(file, encoding, lines, lineEnding);
|
||||
}
|
||||
|
||||
protected void writeLines() throws IOException{
|
||||
|
|
|
@ -234,15 +234,15 @@ public class NossoNumeroUtils {
|
|||
|
||||
public static boolean validaNossoNumero(String nossoNumero, BancoLayout bancoLayout){
|
||||
|
||||
if(BancoLayout.BRADESCO_400_Envio.equals(bancoLayout) && nossoNumero.length() == 12 ){
|
||||
if(BancoLayout.BRADESCO_400_Envio.equals(bancoLayout) && nossoNumero.length() == 13 ){
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
if(BancoLayout.ITAU_400_Envio.equals(bancoLayout) && nossoNumero.length() == 9 ){
|
||||
if(BancoLayout.ITAU_400_Envio.equals(bancoLayout) && nossoNumero.length() == 10 ){
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
if(BancoLayout.BB_240_Envio.equals(bancoLayout)){
|
||||
if(BancoLayout.BB_240_Envio.equals(bancoLayout) && (nossoNumero.length() == 13 || nossoNumero.length() == 17)){
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue