最近在做个MP3播放器,出现中文乱码问题,在网上找了很多解决办法,我整理了出现乱码的点和解决方案,拿出来和大家共享一下
1.读取中文文件乱码解决方法
package com.apj.conv; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.widget.TextView; public class ConverActivity extends Activity { private TextView textview ; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textview = (TextView) findViewById(R.id.lrctext); System.out.println("===================convertCodeAndGetText begin=================== "); ///获得SDCard中文件的路径 String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator ; String tochinese = convertCodeAndGetText(path+"a.txt"); System.out.println(tochinese); System.out.println("===================cconvertCodeAndGetText end==================="); textview.setText(tochinese); } public String convertCodeAndGetText(String str_filepath) {//