package PbuliClass;
|
import java.io.IOException;
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
import javax.swing.JOptionPane;
|
import Method.MiMi;
|
|
/**¸ÃÀàÓÃÓÚ»ñÈ¡Îı¾ÎĵµÖеÄÄÚÈÝ*/
|
public class GetTxt {
|
|
public static String getTxt(String title,String pathName) {
|
String name=null;
|
String path="systemFiles/"+pathName+".txt";
|
String txt;
|
try {
|
txt = ReadFiles.readFiletxt(path);
|
String[] message=txt.split("\\n");//ÒÔ¡°£¬¡±·Ö¸î×Ö·û´®
|
for(int i=0;i<message.length;i++) {
|
String me=message[i];
|
String[] txtn=me.split("\\:");//ÒÔ¡°£¬¡±·Ö¸î×Ö·û´®
|
if(me.startsWith(title)) {
|
name=replace(txtn[1]);
|
break;
|
}
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
JOptionPane.showMessageDialog(null, "¼ì²ésystem.txtÎļþ£¡");// ²¶»ñÒì³£ºó£¬µ¯³öÌáʾ¿ò
|
System.exit(-1);// ϵͳֹͣÔËÐÐ
|
}
|
|
return name;
|
}
|
|
/**»ñÈ¡Èí¼þÊÔÓÃÌìÊý*/
|
public static int get_regis() {
|
int regis=0;
|
String path="systemFiles/regis.txt";
|
String txt;
|
try {
|
txt = ReadFiles.readFiletxt(path);
|
String mimi=MiMi.DecodePasswd(txt);//½âÃÜ
|
String[] message=mimi.split("\\n");//ÒÔ¡°\n¡±·Ö¸î×Ö·û´®
|
for(int i=0;i<message.length;i++) {
|
String me=message[i];
|
String[] txtn=me.split("\\:");//ÒÔ¡°:¡±·Ö¸î×Ö·û´®
|
if(me.startsWith("day")) {
|
String day=txtn[1];
|
regis=Integer.parseInt(day);
|
|
break;
|
}
|
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
JOptionPane.showMessageDialog(null, "¶ÁÎļþ³ö´í£¡");// ²¶»ñÒì³£ºó£¬µ¯³öÌáʾ¿ò
|
System.exit(-1);// ϵͳֹͣÔËÐÐ
|
}
|
return regis;
|
}
|
|
/**È¥µô×Ö·û´®ÖеĻ»Ðпոñ»Ø³µ*/
|
public static String replace(String str) {
|
String destination = "";
|
if (str!=null) {
|
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
Matcher m = p.matcher(str);
|
destination = m.replaceAll("");
|
}
|
return destination;
|
}
|
|
|
}
|