当前位置: 编程技术>移动开发
本页文章导读:
▪利用bufferreader读取文件时解决gbk的字符有关问题 利用bufferreader读取文件时解决gbk的字符问题
/**
* 读取.txt文件
*
* @param path 文件路径
* @return txt文件内容
* @throws IOException IOException
*/
public static String readTxt(String path) t.........
▪ 险些忘记List传的是引用 差点忘记List传的是引用
List<String> data = new ArrayList<String>();
HashMap<String, List<String>> hashMap = new HashMap<String, List<String>>();
hashMap.put("1", data);
Log.i("test", "Hashmap size now.........
▪ 通话完了的时候将自己的应用注册Action 通话结束的时候将自己的应用注册Action
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category .........
[1]利用bufferreader读取文件时解决gbk的字符有关问题
来源: 互联网 发布时间: 2014-02-18
利用bufferreader读取文件时解决gbk的字符问题
/**
* 读取.txt文件
*
* @param path 文件路径
* @return txt文件内容
* @throws IOException IOException
*/
public static String readTxt(String path) throws IOException {
File file = new File(path);
if (!file.exists() || file.isDirectory()) {
throw new FileNotFoundException();
}
BufferedReader reader =
new BufferedReader(
new InputStreamReader(new FileInputStream(file), Constant.ENCODING_GBK));
StringBuilder builder = new StringBuilder();
String separator = System.getProperty("line.separator");
String temp = reader.readLine();
while (temp != null) {
temp = temp.trim();
builder.append(temp).append(separator);
temp = reader.readLine();
}
reader.close();
return builder.toString();
}
[2] 险些忘记List传的是引用
来源: 互联网 发布时间: 2014-02-18
差点忘记List传的是引用
List<String> data = new ArrayList<String>();
HashMap<String, List<String>> hashMap = new HashMap<String, List<String>>();
hashMap.put("1", data);
Log.i("test", "Hashmap size now is 1: " + hashMap.size());
List<String> list = hashMap.get("1");
Log.i("test", "List size must be 0: " + list.size());
data.add("8");
data.add("9");
Log.i("test", "List size : " + list.size());
可以先把List放进Map中,再操作List,反正是传引用不是传值!
[3] 通话完了的时候将自己的应用注册Action
来源: 互联网 发布时间: 2014-02-18
通话结束的时候将自己的应用注册Action
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="vnd.android.cursor.dir/calls" />
</intent-filter>
当你挂断电话的时候,logcat中捕获日志:
03-07 15:07:51.472: I/ActivityManager (154): START {act=android.intent.action.VIEW typ=vnd.android.cursor.dir/calls flg=0x10000 cmp=android/com.android.internal.app.ResolverActivity} from pid 337
明白了吧?
最新技术文章: