Richfaces fileupload

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 ?

Eu fiz uma vez isso da seguinte maneira:


    public void upload(UploadEvent event) throws IOException {
	    UploadItem item = event.getUploadItem();
	    File arq = item.getFile();
	    this.fileName = item.getFileName();
	    byte[] foto = this.getBytesFromFile(arq);
	    try
            {
    		File arqu = new File("C:\\temp\\" + item.getFileName());
                OutputStream out = new FileOutputStream(arqu.getAbsolutePath());
                out.write(foto);
                out.close();
            }
                catch (IOException e) {
            }

    }


    private byte[] getBytesFromFile(File file) throws IOException {
        InputStream is = new FileInputStream(file);
    
        long length = file.length();
    
        if (length > Integer.MAX_VALUE) {
            // File is too large
        }
    
        byte[] bytes = new byte[(int)length];
    
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length
               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        }
    
        if (offset < bytes.length) {
            throw new IOException("Could not completely read file "+file.getName());
        }
    
        is.close();
        return bytes;
    }

Tenta ai.
Até.