String separetor = File.separator;
// 獲取系統的文件分隔符
System.getProperty("user.dir")
// 得到當前的工做路徑
//編碼
ByteBuffer buffer = cset.encode("dafafe");
byte[] bytes = buffer.array();
//轉碼
byte[] byt={1,2};
ByteBuffer bbuf = ByteBuffer.wrap(byt);
CharBuffer cbuf = cset.decode(bbuf);
String str = cbuf.toString();
StringTokenizer t = new StringTokenizer(s, "|"); // 分隔符工具
//文件過濾
public class ExtensionFilter implements FilenameFilter {
private String extension;
public ExtensionFilter(String ext){
extension = "."+ext;
}
@Override
public boolean accept(File dir, String name) {
return name.endsWith(extension);
}
}
//使用
File directory=new File(filename);
String[] files = directory.list(new ExtensionFilter());