new BufferedReader(
new FileReader("data.txt"));
String read = "";
while ((read = in.readLine())!=null)
System.out.println(read);
}catch(IOException e){}
}
public static void timeOut(double sec)//停顿短暂时间的一个方法完全可以不要这个功能
{
double seconds = sec;
long t = System.currentTimeMillis()+(int)(seconds*1000);
while ((System.currentTimeMillis())<t)
;
}
public void numSort()//按学号排序
throws IOException
{
long i = 0;
String s = "";
try{
DataArrayList dal = new DataArrayList();
BufferedReader in =
new BufferedReader(
new FileReader("data.txt"));
while ((s=in.readLine())!=null)
{
i=numberTokenizer(s);
dal.add(i);
}
Collections.sort(dal);
DataMap dm = new DataMap();
BufferedReader in2 =
new BufferedReader(
new FileReader("data.txt"));
while ((s=in2.readLine())!=null)
{
i=numberTokenizer(s);
dm.put(i,s);
}
PrintWriter out =
new PrintWriter (
new BufferedWriter(
new FileWriter("data.txt")));
Iterator it = dal.iterator();
long temp = 0;
String tempStr = "";
while (it.hasNext())
{
temp = Integer.valueOf((String)it.next()).longValue();
tempStr = dm.get(temp);
out.println(tempStr);
}
out.close();
}catch(IOException e){}
}
public void rewrite()
throws IOException,NumberNotFoundException
{
try{
System.out.print("请输入你要修改的学生学号:");
BufferedReader in =
new BufferedReader (
new InputStreamReader(System.in));
String inputLine = in.readLine();
long num = Integer.valueOf(inputLine).longValue();
findData(num);
if(isFind)
{
deleteData(num);
System.out.print("请重新输入该学生的资料:");
String str = inputData();
addData(str);
System.out.println("rewrite true!");
}
}catch(IOException e){}
catch(NumberNotFoundException e){}
}
public int count()
throws IOException
{
DataArrayList dal = new DataArrayList();
try{
new FileReader("data.txt"));
String read = "";
while ((read = in.readLine())!=null)
System.out.println(read);
}catch(IOException e){}
}
public static void timeOut(double sec)//停顿短暂时间的一个方法完全可以不要这个功能
{
double seconds = sec;
long t = System.currentTimeMillis()+(int)(seconds*1000);
while ((System.currentTimeMillis())<t)
;
}
public void numSort()//按学号排序
throws IOException
{
long i = 0;
String s = "";
try{
DataArrayList dal = new DataArrayList();
BufferedReader in =
new BufferedReader(
new FileReader("data.txt"));
while ((s=in.readLine())!=null)
{
i=numberTokenizer(s);
dal.add(i);
}
Collections.sort(dal);
DataMap dm = new DataMap();
BufferedReader in2 =
new BufferedReader(
new FileReader("data.txt"));
while ((s=in2.readLine())!=null)
{
i=numberTokenizer(s);
dm.put(i,s);
}
PrintWriter out =
new PrintWriter (
new BufferedWriter(
new FileWriter("data.txt")));
Iterator it = dal.iterator();
long temp = 0;
String tempStr = "";
while (it.hasNext())
{
temp = Integer.valueOf((String)it.next()).longValue();
tempStr = dm.get(temp);
out.println(tempStr);
}
out.close();
}catch(IOException e){}
}
public void rewrite()
throws IOException,NumberNotFoundException
{
try{
System.out.print("请输入你要修改的学生学号:");
BufferedReader in =
new BufferedReader (
new InputStreamReader(System.in));
String inputLine = in.readLine();
long num = Integer.valueOf(inputLine).longValue();
findData(num);
if(isFind)
{
deleteData(num);
System.out.print("请重新输入该学生的资料:");
String str = inputData();
addData(str);
System.out.println("rewrite true!");
}
}catch(IOException e){}
catch(NumberNotFoundException e){}
}
public int count()
throws IOException
{
DataArrayList dal = new DataArrayList();
try{
| 对此文章发表了评论 |
