Galera estou com uma duvida..
tenho um método que me retorna uma string de caracteres.. normal ateh ai sem problemas..
e ja esta funcionando tudo de boas...
o meu problema.. eu tenho um cara chamado "codigoRetorno" que eu preciso retorna-lo tambem juntamente com o "arquivo"(a string que preciso devolver)
esse codigo retorno informa se houve algum erro ou se tudo ocorreu bem, como posso fazer para retornar os dois juntos ??? tem como eu retornar os dois parametros?
sendo que um é do tipo String e o outro é do tipo FT17ResponseVO ???
segue o meu código abaixo
if (requestVO.getCodigoProduto().equals("DC")) {
log.info("Handling FT17 request");
try {
IntegLayerProperties properties = IntegLayerProperties.getInstance();
if (requestVO.getDiretorio().equals(FT17RequestVO.CAIXA_REMESSA)) {
source = properties.getProperty(C_SOURCE_DIRECTORY);
} else {
source = properties.getProperty(C_TARGET_DIRECTORY);
}
} catch (IntegLayerException e) {
throw new HandleException(
IntegLayerErrorCodes.ERROR_RETRIEVING_PROPERTY, e);
}
// busca o respectivo arquivo no diretório especificado e seta em
// "arquivo retorno"
responseVO.setArquivoRetorno(downloadarquivo(source, requestVO)); //chamada do método que vou utilizar... <<<<<<<<<<<<<<
log.debug("<< Handle FT17 - Receber Remessa");
} else {
log.debug(">> Handle FT17 - Retorno...");
FT17ResponseVO response = new FT17ResponseVO();
response.setArquivoRetorno(doFTP(requestVO));
log.debug("<< Handle FT17 - Receber Remessa");
}
return responseVO;
}
Método que tenho duvida no retorno
private String downloadarquivo(String source, FT17RequestVO requestVO)throws HandleException { //método do tipo string
FT17ResponseVO responseVO = new FT17ResponseVO();
String arquivo = "";
try {
LocalFileUtil fileUtil = new LocalFileUtil(source);
List<File> files = fileUtil.getFiles("");
byte[] buf = new byte[1024];
int len = 0;
log.info("Generating FT17 download of object");
for (File file : files) {
InputStream in = null;
ByteArrayOutputStream out = null;
try {
in = new FileInputStream(file);
out = new ByteArrayOutputStream();
if (file.getName().contains(requestVO.getNomeArquivo())) {
len = in.read(buf);
out.write(buf, 0, len);
out.flush();
// arquivo convertido para base 64
arquivo = Base64.encode(out.toByteArray());
responseVO.setCodigoRetorno(0); //código retorno que preciso retornar
}
} catch (Exception e) {
log.warn("Fail to download file " + file.getName()
+ " in responseVO", e);
responseVO.setCodigoRetorno(1);
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (IOException e) {
log.warn(
"Fail to close streams for file "
+ file.getName(), e);
responseVO.setCodigoRetorno(1); //código retorno que preciso retornar
}
}
}
} catch (IntegLayerException e) {
throw new HandleException(
IntegLayerErrorCodes.ERROR_BUILDING_RESPONSE, e);
}
return arquivo; //string que eu retorno , aqui preciso retornar tbm o código retorno..
}
vlw galera grato !!