What is the Exception in thread "Smack-Cached Executor 10 (0)"?

415 Views Asked by At

What is the Exception in thread "Smack-Cached Executor 10 (0)" java.lang.IndexOutOfBoundsException?

I created a client in java for a desktop application with the Smack library and receiving a file from a Spark client throws this exception:

Exception in thread "Smack-Cached Executor 0 (0)" java.lang.IndexOutOfBoundsException
At java.io.FileOutputStream.writeBytes (Native Method)
At java.io.FileOutputStream.write (FileOutputStream.java:326)
At java.io.DataOutputStream.write (DataOutputStream.java:107)
At model.MessagingManagment $ 2.fileTransferRequest (MessagingManagment.java:171)
At org.jivesoftware.smackx.filetransfer.FileTransferManager $ 1.handleIQRequest (FileTransferManager.java:80)
At org.jivesoftware.smack.AbstractXMPPConnection $ 2.run (AbstractXMPPConnection.java:1061)
At java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
At java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617)
At java.lang.Thread.run (Thread.java:745)

This is the code that receives the file I am receiving:

private void IncomingFileTransfer(){
        FileTransferManager fileManage = FileTransferManager.getInstanceFor(ChatRoomConstants.connection);
        fileManage.addFileTransferListener(new FileTransferListener() {

            @Override
            public void fileTransferRequest(FileTransferRequest request) {

                try {
                    if (JOptionPane.showConfirmDialog(null,"receive the file?")==JOptionPane.YES_OPTION) {
                        IncomingFileTransfer transfer = request.accept();
                        InputStream inputStrea = transfer.recieveFile();
                        String filePath = new File(".").getCanonicalPath()+"\\ChatFiles";
                        File file = new File(filePath);
                        file.mkdirs();
                        File files = new File(filePath, transfer.getFileName());
                        DataOutputStream dataStream = new DataOutputStream(new FileOutputStream(files));
                        int reader;
                        byte[] buffer = new byte[2048]; //sujeto al tamaño disponible por el cache de lectura del DD
                        while ((reader=inputStrea.read(buffer,0,buffer.length))!=1) {  
                            dataStream.write(buffer, 0, reader);
                        }
                        dataStream.flush();
                        dataStream.close();
                    }else{
                        request.reject();
                    }
                } catch (SmackException e) {
                    e.printStackTrace();
                } catch (XMPPException.XMPPErrorException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }finally{
                }
            }
        });
    }
0

There are 0 best solutions below