Ai
2 Star 0 Fork 0

Paparazzi/软工结对编程

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Histroy.java 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
Paparazzi 提交于 2018-03-25 14:53 +08:00 . 修改
package szys;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Histroy {
String qstr;
String astr;
String str;
String str2 = "0 0";
double tot = 0;
double rn = 0;
public List<String> qstrlist = new ArrayList<String>();
public List<String> astrlist = new ArrayList<String>();
public Histroy() {
}
public void scan(String qstr, String astr) {
str = (astr + " " + qstr);
}
public void scan2(int tot, int rn) {
str2 = (tot + " " + rn);
}
public void Histroy_create() {
String path = "f:\\Myapp";
File f = new File(path);
if (!f.exists()) {
f.mkdirs();
String fileName = "histroy.txt";
File file = new File(f, fileName);
if (!file.exists()) {
Writer writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
} catch (UnsupportedEncodingException | FileNotFoundException e) {
e.printStackTrace();
}
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
f.mkdirs();
String fileName2 = "histroy_num.txt";
File file2 = new File(f, fileName2);
if (!file2.exists()) {
Writer writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(file2), "UTF-8");
} catch (UnsupportedEncodingException | FileNotFoundException e) {
e.printStackTrace();
}
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Histroy_saveNum();
}
}
public void Histroy_save() {
FileWriter writer;
String fileName = ("f:\\Myapp\\histroy.txt");
try {
writer = new FileWriter(fileName, true);
writer.write(str);
writer.write("\r\n");
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void Histroy_saveNum() {
FileWriter writer2;
String fileName2 = ("f:\\Myapp\\histroy_num.txt");
try {
writer2 = new FileWriter(fileName2, true);
writer2.write(str2);
writer2.write("\r\n");
writer2.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void Histroy_read() throws FileNotFoundException {
Scanner in = new Scanner(new File("f:\\Myapp\\histroy.txt"), "UTF-8");// 为历史信息.tit这个File创建一个扫描器in
while (in.hasNextLine()) {
String line = in.nextLine();// 读出历史信息.txt的下一行
Scanner lineScanner = new Scanner(line);// 为每一行建立一个扫描器
lineScanner.useDelimiter(" ");// 使用空格作为分隔符
qstr = lineScanner.next();// 问题
astr = lineScanner.next();// 答案
qstrlist.add(qstr);
astrlist.add(astr);
}
in.close();
}
public void History_num() throws FileNotFoundException {
Scanner in = new Scanner(new File("f:\\Myapp\\histroy_num.txt"), "UTF-8");// 为历史信息.tit这个File创建一个扫描器in
while (in.hasNextLine()) {
String line = in.nextLine();// 读出历史信息.txt的下一行
Scanner lineScanner = new Scanner(line);// 为每一行建立一个扫描器
lineScanner.useDelimiter(" ");// 使用空格作为分隔符
tot = Integer.parseInt(lineScanner.next());// 问题
rn = Integer.parseInt(lineScanner.next());// 答案
}
in.close();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/huangsh1/software_pair_programming.git
git@gitee.com:huangsh1/software_pair_programming.git
huangsh1
software_pair_programming
软工结对编程
master

搜索帮助