[jcifs] first attempt

Richard Caper rcaper at gmail.com
Tue May 30 15:25:47 GMT 2006


jCIFS uses SMB URLS rather than UNC paths ("\\server\share").  for
your example it would be:

SmbFile f = new SmbFile("smb://C62033/ShareTest/TestFile.txt");



On 5/30/06, David McDivitt <x12code at yahoo.com> wrote:
> Hi,
>
> I need a java app to get files from a Windows workstation. I found JCIFS and
> downloaded. On another workstation in this room I set up a shared folder. It
> has no user name or password. On my workstation I can click START, RUN then
> put in \\C62033\ShareTest and see the folder. I can use the IP adress, too.
> My test class is pasted below. The string 1x.3x.1x.2x is the IP address, but
> changed for this email. I copied stuff from the example. If someone could
> tell me what I'm missing I'd appreciate it. Thanks
>
>
>
> package test;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> import jcifs.smb.SmbFile;
>
> public class JcifsTest01 {
>
>     static final String TYPES[] = {
>         "TYPE_COMM",
>         "TYPE_FILESYSTEM",
>         "TYPE_NAMED_PIPE",
>         "TYPE_PRINTER",
>         "TYPE_SERVER",
>         "TYPE_SHARE",
>         "TYPE_WORKGROUP"
>     };
>
>     public static void main(String[] args) throws Exception {
>         jcifs.Config.registerSmbURLHandler();
>         jcifs.Config.setProperty("jcifs.smb.client.domain","Dpadom");
>         jcifs.Config.setProperty("jcifs.smb.client.username","");
>         jcifs.Config.setProperty("jcifs.smb.client.password","");
>         jcifs.Config.setProperty("jcifs.resolveOrder","DNS,WINS");
>
>         SmbFile f = new SmbFile("//C62033/");
>         //SmbFile f = new SmbFile("//C62033/ShareTest/TestFile.txt");
>         //SmbFile f = new SmbFile("\\\\C62033\\ShareTest\\TestFile.txt");
>         //SmbFile f = new SmbFile("//1x.3x.1x.2x/ShareTest/TestFile.txt");
>         //SmbFile f = new
> SmbFile("\\\\1x.3x.1x.2x\\ShareTest\\TestFile.txt");
>
>         SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yy hh:mm:ss a"
> );
>         System.out.println( "        toString: " + f.toString() );
>         System.out.println( "           toURL: " + f.toURL() );
>         System.out.println( "         getName: " + f.getName() );
>         System.out.println( "          length: " + f.length() );
>         System.out.println( " getLastModified: " + sdf.format( new Date(
> f.getLastModified() )));
>         System.out.println( "        isHidden: " + f.isHidden() );
>         System.out.println( "          isFile: " + f.isFile() );
>         System.out.println( "     isDirectory: " + f.isDirectory() );
>         System.out.println( "        hashCode: " + f.hashCode() );
>         System.out.println( "      getUncPath: " + f.getUncPath() );
>         System.out.println( "         getType: " + TYPES[f.getType()] );
>         System.out.println( "        getShare: " + f.getShare() );
>         System.out.println( "       getServer: " + f.getServer() );
>         System.out.println( "         getPath: " + f.getPath() );
>         System.out.println( "       getParent: " + f.getParent() );
>         System.out.println( "    lastModified: " + sdf.format( new Date(
> f.lastModified() )));
>         System.out.println( "getDiskFreeSpace: " + f.getDiskFreeSpace() );
>         System.out.println( "         getDate: " + sdf.format( new Date(
> f.getDate() )));
>         System.out.println( "getContentLength: " + f.getContentLength() );
>         System.out.println( "getCanonicalPath: " + f.getCanonicalPath() );
>         System.out.println( "          exists: " + f.exists() );
>         System.out.println( "         canRead: " + f.canRead() );
>         System.out.println( "        canWrite: " + f.canWrite() );
>     }
> }
>
>


More information about the jcifs mailing list