[jcifs] Accessing a local file using SmbFile

Michael B. Allen miallen at eskimo.com
Thu Feb 27 08:25:33 EST 2003


On Wed, 26 Feb 2003 21:02:12 +0800
Agnes <acsy11 at yahoo.com.sg> wrote:

> Hi,
> 
> Thanks of your prompt help!
> 
> I've got the code part already.  
> 
> >	Is your NT domain really 'testdomain.com.sg'? Also you do not specify a share
> >	which will definately be a problem but it should not give you "Connection refused".
> 
> 
> As for the domain setting and share, it's the domain of my AIX machine, 
> and I don't think it's on an NT domain.  Also, how to specify a share on 
> AIX without having to install Samba?

It's not clear to me what you are trying to achive. Are you trying to
copy a file from one location to another? Let's say for example you are
running a Java program on AIX that needs to read a file from a Windows
2000 share and print it to System.out. You might use the following code:

  import jcifs.smb.*;
  
  jcifs.Config.setProperty( "wins", "192.168.1.230" );
  SmbFileInputStream in = new SmbFileInputStream(
       "smb://username:password@w2ksvr/tmep/report.txt" );
  byte[] b = new byte[8192];
  int n;
  while(( n = in.read( b )) > 0 ) {
      System.out.write( b, 0, n );
  }

To write the contents of report.txt to a file on the AIX machine you
would simply write the buffer to a FileOutputStream.

If you are trying to read a file from an AIX machine remotely jCIFS is
not what you want. You would need to ask the system administrator what
file sharing options are available on the machine.

Mike

-- 
A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 


More information about the jcifs mailing list