0

我试图在我的网络中访问此文件 \192.168.1.1\d$\IISFolders\ftp\teste.png 以获取他的字节并放入一个 json 文件并发送。但是要访问这个目录,我需要 Authenticate..

json.replace( a.getImage()/*string no ads.getimage()*/, 
  new Base64Encode( "//192.168.1.1//d$//IISFolders//ftp//"+a.getImage() ).encode()/*base64 string image*/ );

/* The encode code - already tested works fine */
public String encode() throws IOException
{
    byte[] bytes = new byte[ 2048 ];
    byte[] result = new  byte[ (int) target.length() ];
    int ibytes;
    int counter = 0;

    while( ( ibytes = bis.read(bytes) ) != -1 ) /* Read from buffIn */
    {
        System.arraycopy(bytes, 0, result, counter, ibytes);
        counter += ibytes;
    }

    return new String( Base64.encodeBase64( result ) );
}

当我运行代码时,应用程序找不到文件...抛出java.io.FileNotFoundException: \\192.168.1.1\d$\IISFolders\ftp\teste.png和(用户名和/或密码错误)...

我怎么能访问这个目录和他的文件?

4

1 回答 1

1

试试这个:

FTPClient f = new FTPClient();
f.connect("//192.168.1.1//d$//IISFolders//ftp//");
f.login("foo", "bar");
InputStream is = retrieveFileStream(a.getImage());
...

在这里查看更多信息:FTPClient

于 2013-09-24T12:17:11.867 回答