[jcifs] Strange issue with SmbFileInputStream

René Liebmann rene_liebmann at datamatics.de
Wed Jan 27 09:35:36 MST 2010


Hi all,

 

I have a small function which I use to copy a remote file to my local
machine. On almost all environments (Win XP Home) this works fine, but on a
Windows 2003 Server environment it does only copy a small portion of a file
e.g. if the file is 6 MB large it copies 248 kB. Then it seems that it never
leaves the while block and my program hangs. It does not throw any
exception. What am I doing wrong?

 

private void copySmbFileTo(SmbFile f, String location) throws IOException {

        logger.debug(name + " enter function copySmbFileTo "+f.getUncPath()
+ " to "+location);

 

        SmbFileInputStream istr = null;

        OutputStream ostr = null;

        try {  // 1

            istr = new SmbFileInputStream(f);

            ostr = new FileOutputStream(location);

            byte[] buf1 = new byte[1024];

            int len1;

            while((len1 = istr.read(buf1)) > 0){

                ostr.write(buf1, 0, len1);

            }

            ostr.flush(); 

        } catch(Exception ex){

            logger.error("", ex);

        } finally{

          try { // 2

            if(istr!=null)  istr.close();

            if(ostr!=null)  ostr.close();

          } catch(Exception ex){

              logger.error("Major Error Releasing Streams:", ex);

 

          } // End try catch number 2

        } // End try catch finally number 1

        logger.debug(name + " leave function copySmbFileTo");

 

    }

 

Thanks for your ideas in advance

 

René 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20100127/54260f08/attachment.html>


More information about the jCIFS mailing list