android学习之smb-jcifs

来源:互联网 发布:指纹充电软件下载 编辑:程序博客网 时间:2024/06/06 18:55

public static void smbGet(String remoteUrl,StringlocalDir){
  InputStream in = null;
  FileOutputStream out =null;
  try {
   SmbFilesmbFile = new SmbFile(remoteUrl);
   StringfileName = smbFile.getName();
   FilelocalFile = new File(localDir+File.separator+fileName);
   in = newBufferedInputStream(new SmbFileInputStream(smbFile));
   out = newFileOutputStream(localFile);
   byte []buffer= new byte[1024];
   while((in.read(buffer))!= -1){
    out.write(buffer);
    buffer= new byte[1024];
   }
  } catch (Exception e) {
   e.printStackTrace();
  }finally{
   try {
    out.close();
    in.close();
   } catch(IOException e) {
    e.printStackTrace();
   }
  }
 }
 
 
 public static void smbPut(String remoteUrl,StringlocalFilePath){
  InputStream in = null;
  OutputStream out = null;
  try {
   FilelocalFile = new File(localFilePath);
   StringfileName = localFile.getName();
   SmbFileremoteFile = new SmbFile(remoteUrl+"/"+fileName);
   in = newBufferedInputStream(new FileInputStream(localFile));
   out = newSmbFileOutputStream(remoteFile);
   byte []buffer= new byte[1024];
   while((in.read(buffer))!= -1){
    out.write(buffer);
    buffer= new byte[1024];
   }
  } catch (Exception e) {
   e.printStackTrace();
  }finally{
   try {
    out.close();
    in.close();
   } catch(IOException e) {
    e.printStackTrace();
   }
  }
 }

smbPut("smb://administrator:*******@192.***.***.****/dfcxact/pretest/mtsn/4c680001.EBT","/mnt/sdcard/test.INI"); 

smbGet("smb://administrator:*******@192.***.***.****//dfcxact/pretest/mtsn/4c680001.EBT/STANDARD.INI","/mnt/sdcard/");

0 0
原创粉丝点击