【问题标题】:Android JCIFS write file to shared network folder (Can't connect to server)Android JCIFS 将文件写入共享网络文件夹(无法连接到服务器)
【发布时间】:2015-04-22 02:47:24
【问题描述】:

首先根据其他答案,我已经做了一些事情。

1- 为我的清单添加了正确的权限

2- 使用 AsyncTask 子类来处理进程

3- 只是出于好奇,将完全相同的代码复制到了一个非 adroid java 项目中,它工作正常。但是在模拟器上它返回一个'无法连接到服务器'

public class NetworkUploader extends AsyncTask<String,Void,String> {
      private final String TAG = "SSTv1.0";

@Override
protected String doInBackground(String... params) {


       NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("","tom.smith", "abc123456");
       String sharepath = "smb://sed/Production/Test-Android/test.txt";
      try{
          String text = "Hello There";
          SmbFile sFile = new SmbFile(sharepath, auth);
          SmbFileOutputStream out = new SmbFileOutputStream(sFile);
         out.write(text.getBytes());
         out.close();
       }catch(Exception e){
          //e.printStackTrace();
            Log.d(TAG,e.getMessage());

       }

     return null;

 }



    @Override
protected void onPostExecute(String result) {
    //Do something with result

}

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.net.toms.sst" >
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature android:name="android.hardware.camera" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

非常感谢任何反馈

【问题讨论】:

    标签: java android jcifs


    【解决方案1】:

    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null,"tom.smith", "abc123456");

    将空字符串更改为空。

    【讨论】:

      猜你喜欢
      • 2010-10-27
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 2011-01-18
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多