Boa Tarde.
Estou usando o codigo abaixo, mas esta dando a seguinte mensagem: Transfer error occurred.
Verifiquei que esta mensagem está sendo causada por uma NullPointerException quando a seguinte lina de comando é executada: fos.write(item.getData());
Mais precisamente no seguinte comando: item.getData()
<ui:define name="content">
<h:outputText value="Ler Retorno Bancário" styleClass="title"/>
<br/><br/>
<h:form prependId="false" >
<rich:fileUpload fileUploadListener="#{retornoMB.listener}"
id="upload" allowFlash="false"
immediateUpload="false"
acceptedTypes="txt">
</rich:fileUpload>
</h:form>
<br/>
</ui:define>
public void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
String dir = "C:/Users/kivik/Downloads/retorno/";
File file = new File(dir + item.getFileName());
FileOutputStream fos = new FileOutputStream(file);
fos.write(item.getData());
fos.flush();
fos.close();
}
Alguém tem alguma dica ?