我正在编写一个简单的应用程序来学习用于android os的韩语sylabs。 是否可以在android os中使用韩文字符作为文件名? 当我试图从资产dir获取文件时,我得到了这个例外:
07-21 19:33:39.558:W / System.err(7315):java.io.FileNotFoundException: 가.mp3 07-21 19:33:39.558:W / System.err(7315):at android.content.res.AssetManager.openAssetFd(Native Method)07-21 19:33:39.558:W / System.err(7315):at android.content.res.AssetManager.openFd(AssetManager.java:331)07-21 19:33:39.558:W / System.err(7315):at net.garagefarm.hangulteatcher.MainActivity $ 3.onClick(MainActivity.java:141) 07-21 19:33:39.558:W / System.err(7315):at android.view.View.performClick(View.java:4222)07-21 19:33:39.558: W / System.err(7315):at android.view.View $ PerformClick.run(View.java:17273)07-21 19:33:39.558:W / System.err(7315):at android.os.Handler.handleCallback(Handler.java:615)07-21 19:33:39.558:W / System.err(7315):at android.os.Handler.dispatchMessage(Handler.java:92)07-21 19:33:39.566:W / System.err(7315):at android.os.Looper.loop(Looper.java:137)07-21 19:33:39.566: W / System.err(7315):at android.app.ActivityThread.main(ActivityThread.java:4895)07-21 19:33:39.566:W / System.err(7315):at java.lang.reflect.Method.invokeNative(Native Method)07-21 19:33:39.566:W / System.err(7315):at java.lang.reflect.Method.invoke(Method.java:511)07-21 19:33:39.566: W / System.err(7315):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:994) 07-21 19:33:39.566:W / System.err(7315):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)07-21 19:33:39.566:W / System.err(7315):at dalvik.system.NativeStart.main(Native Method)07-21 19:38:39.495: W / IInputConnectionWrapper(7315):getSelectedText处于非活动状态 InputConnection 07-21 19:38:39.495:W / IInputConnectionWrapper(7315): setComposingText在非活动的InputConnection
上
当我将文件名更改为“1.mp3”时,有趣的是一切正常。
以下是加载文件的代码:
num.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (player.isPlaying()) {
player.stop();
}
player.release();
player = new MediaPlayer();
TextView tv = (TextView)v;
AssetManager manager = parent.getAssets();
try {
FileInputStream mp3Stream =
manager.openFd(tv.getText() + ".mp3").createInputStream();
player.setDataSource(
mp3Stream.getFD());
player.prepare();
player.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
matrixSelected(tv);
}
});
来自调试器的: mText“가”(id = 830041403152)
文件名仍然是: 가.MP3