在尝试将文件写入SD卡时,我得到了java.io.FileNotFoundException: /filename (Read-only file system)异常.可悲的是,这里发布的众多解决方案都没有帮助我.我已设置权限,外部存储处于MEDIA_MOUNTED状态.这是有问题的代码:
Log.i("STORAGE", Environment.getExternalStorageState());
OutputStream fos = new FileOutputStream(Helpers.StripExtension(filePath) + ".blk");
fos.write(digest.getBytes());
fos.close();
Run Code Online (Sandbox Code Playgroud)
filePath来自文件自动收报机.我要做的是从所选文件中读取,然后保存另一个具有相同名称,不同扩展名和其中一些内容的文件.
表现:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackagename"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@android:style/Theme.Black" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
logcat的:
10-25 18:24:34.330: I/FILEPATH(1989): /mnt/sdcard/Untitled.txt
10-25 18:24:34.360: I/STORAGE(1989): mounted
10-25 18:24:34.360: W/System.err(1989): java.io.FileNotFoundException: /mnt/sdcard/Untitled.blk (Read-only file system)
10-25 18:24:34.360: W/System.err(1989): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method) …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到以openssl开头的测试服务器(这个有限的密码组合是有意的):
openssl s_server -accept 443 -www -tls1_2 -cipher ECDHE:DHE:EDH -cert selfsignedcert.pem -key sskey.pem
Run Code Online (Sandbox Code Playgroud)
我使用的代码类似于msdn的代码
public static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}
...
var client = new TcpClient(target, port);
SslStream sslStream = new SslStream(client.GetStream(), false,ValidateServerCertificate,null);
sslStream.AuthenticateAsClient(target, null, SslProtocols.Tls12, false);
Run Code Online (Sandbox Code Playgroud)
但是我在最后一行得到一个例外:A call to SSPI failed, see inner exception.内部异常说:The Local Security Authority cannot be contacted.通过查看wireshark,我可以说TLS握手结束Server Hello, Certificate, Server Key Exchange, Server Hello Done并且选择的密码套件是TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 (0x009f).
我可以使用Firefox访问该URL,但不能使用IE(它只是说"此页面无法显示"),因此它看起来像schannel问题.
当我用所有密码套件( …