String
String 与 Byte[]的转换
String s = "abcdefg";
//String转byte[]
byte[] bytes = s.getBytes();
//byte[]转String
String t = new String(bytes);
去掉文件的后缀名,保留后缀名前的String
int index = oldFile.getName().indexOf(".");
String newFileName = oldFile.getName().substring(0, index);
subString(int begignIndex)
String subString(int begignIndex)
返回beginIndex开始,直到最后的String。
"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)
subString(int beginIndex,int lastIndex)
String subString(int begignIndex,int lastIndex)
返回beginIndex开始,到lastIndex的String。包左不包右
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile
HashMap
StringBuffer sb2 = new StringBuffer();
Iterator<Map.Entry<Integer, Boolean>> iterator = adapter.selectMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, Boolean> entry = iterator.next();
Integer key = entry.getKey();
Boolean value = entry.getValue();
if (!value) {
sb2.append(key + ",");
}
}
枚举(enum)
//枚举:定义4中加载状态
enum PagerState{
STATE_LOADING(1),
STATE_EMPTY(2),
STATE_ERROR(3),
STATE_SUCCESS(4);
private int value;
PagerState(int value){
this.value = value;
}
public int getValue(){
return value;
}
}