import java.io.*;
import java.util.LinkedList;
public class File类 {
public File类() {
}
//===============1===============
public void writer(String list) throws IOException {
String[] strings = list.split(",");
//在几班,从String中获取数字
String str = strings[4].trim();
String string1 = "";
if (str != null && !"".equals(str)) {
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
string1 += str.charAt(i);
}
}
}
int x = Integer.parseInt(string1);
//学号,从String中获取数字
String string2 = strings[0].trim();
String string3 = "";
if (string2 != null && !"".equals(string2)) {
for (int i = 0; i < string2.length(); i++) {
if (string2.charAt(i) >= 48 && string2.charAt(i) <= 57) {
string3 += string2.charAt(i);
}
}
}
int a = Integer.parseInt(string3);
//目录
File file = new File("E:\\student");
File file1 = new File("E:\\student\\classNum" + x);
String string = "";
String[] strings3 = file.list();
for (String s : strings3) {
string += s;
}
//获取目录下的所有文件名称
if (string.contains("E:\\student\\classNum" + x)) {
//文件.txt
String str1 = "E:\\student\\classNum" + x + "\\student" + a + ".txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(str1, true));
bw.write(list);
bw.newLine();
bw.flush();
bw.close();
} else {
//不存在file1
String str2 = "E:\\student\\classNum" + x;
File file2 = new File(str2);
//创建新班级
file2.mkdir();
String str1 = str2 + "\\student" + a + ".txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(str1, true));
bw.write(list);
bw.newLine();
bw.flush();
bw.close();
}
}
//===============2===============
public void delStudent(int stuNum) throws IOException {
String s1 = "stuNum=" + stuNum;
String s2 = getAll();
String[] strings1 = s2.split("\n");
//从全部信息中获得哪一个是学号是stuNum的学生信息
int x = 0;
for (int i = 0; i < strings1.length; i++) {
if (strings1[i].contains(s1)) {
x = i;
break;
}
}
//获得班号
String[] strings = strings1[x].split(",");
try {
String string2 = strings[4].trim();
String string3 = "";
if (string2 != null && !"".equals(string2)) {
for (int i = 0; i < string2.length(); i++) {
if (string2.charAt(i) >= 48 && string2.charAt(i) <= 57) {
string3 += string2.charAt(i);
}
}
}
//班号
int a = Integer.parseInt(string3);
String s3 = "E:\\student\\classNum" + a + "\\student" + stuNum + ".txt";
File file = new File(s3);
//判断是否删除成功
if (file.delete()) {
System.out.println("删除成功");
} else if (!file.exists()) {
System.out.println("删除失败,该学生不存在");
}
} catch (ArrayIndexOutOfBoundsException e) {
}
}
//获取全部学生信息,并返回学生信息的字符串;
public String getAll() throws IOException {
String s1 = "";
String s3 = "";
String s5 = "";
LinkedList<String> lii = new LinkedList<>();
File file = new File("E:\\student");
File[] files = file.listFiles();
for (File F : files) {
s1 += F.getAbsolutePath();
}
String[] strings = s1.split("E");
for (int i = 1; i < strings.length; i++) {
String s2 = "E" + strings[i];
File file1 = new File(s2);
File[] files1 = file1.listFiles();
for (File F : files1) {
s3 += F.getAbsolutePath();
}
}
String[] strings1 = s3.split("E");
for (int i = 1; i < strings1.length; i++) {
String s4 = "E" + strings1[i];
File file1 = new File(s4);
BufferedReader br = new BufferedReader(new FileReader(file1));
lii.add(br.readLine());
br.close();
}
for (int i = 0; i < lii.size(); i++) {
s5 += lii.get(i) + "\n";
}
return s5;
}
//===============3===============
public void age加() throws IOException {
String[] strings = getAll().split("\n");
for (int i = 0; i < strings.length; i++) {
String[] strings1 = strings[i].split(",");
//stuNum是几
String string2 = strings1[0].trim();
String string3 = "";
if (string2 != null && !"".equals(string2)) {
for (int j = 0; j < string2.length(); j++) {
if (string2.charAt(j) >= 48 && string2.charAt(j) <= 57) {
string3 += string2.charAt(j);
}
}
}
//学号
int a = Integer.parseInt(string3);
//classNum是几
String string4 = strings1[4].trim();
String string5 = "";
if (string4 != null && !"".equals(string4)) {
for (int k = 0; k < string4.length(); k++) {
if (string4.charAt(k) >= 48 && string4.charAt(k) <= 57) {
string5 += string4.charAt(k);
}
}
}
//班号
int b = Integer.parseInt(string5);
//age是几
String string6 = strings1[3].trim();
String string7 = "";
if (string6 != null && !"".equals(string6)) {
for (int l = 0; l < string6.length(); l++) {
if (string6.charAt(l) >= 48 && string6.charAt(l) <= 57) {
string7 += string6.charAt(l);
}
}
}
//年龄
int c = Integer.parseInt(string7) + 1;
String s = "E:\\student\\classNum" + b + "\\student" + a + ".txt";
File file1 = new File(s);
file1.delete();
File file = new File(s);
String s1 = strings1[0] + "," + strings1[1] + "," + strings1[2] + ", " + "age=" + c + "," + strings1[4];
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
bw.write(s1);
bw.close();
} catch (FileNotFoundException e) {
}
}
System.out.println("操作成功");
}
//===============4===============
public void shift(int stuNum, int classNum, String classNum1) throws IOException {
//转移前的路径
String s1 = "E:\\student\\classNum" + classNum + "\\student" + stuNum + ".txt";
File file1 = new File(s1);
//转移后的路径
String s2 = "E:\\student\\classNum" + classNum1 + "\\student" + stuNum + ".txt";
File file = new File(s2);
try {
BufferedReader br = new BufferedReader(new FileReader(s1));
BufferedWriter bw = new BufferedWriter(new FileWriter(s2));
String line;
while ((line = br.readLine()) != null) {
String[] strings = line.split(",");
String s3 = "classNum=" + classNum1 + "}";
String s4 = strings[0] + "," + strings[1] + "," + strings[2] + "," + strings[3] + ", " + s3;
bw.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是基于Java的JavaEE企业级应用设计源码,包含357个文件,其中包括346个Java源文件、7个TXT文本文件、2个PNG图像文件、1个Properties配置文件和1个PDF文档。系统专注于提供企业级应用功能,支持用户管理、权限控制等功能,为用户提供了一个稳定、高效的JavaEE应用开发平台。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的JavaEE企业级应用设计源码 (360个子文件)
File类.java 10KB
班级学生管理程序.java 3KB
容器.java 2KB
student.java 2KB
_01List集合特有方法.java 2KB
student.java 2KB
_02输出写数据.java 2KB
读取1.java 2KB
_03判断和获取.java 2KB
InterfaceAbstract.java 2KB
LinkedList方法.java 2KB
MyThread.java 2KB
读取.java 2KB
GetArea.java 2KB
样例一.java 2KB
JumppingObject.java 2KB
Book.java 2KB
ArrayList常用方法和遍历.java 2KB
文件.java 2KB
Test.java 2KB
遍历目录递归.java 2KB
Client.java 2KB
flowLayout.java 2KB
gridLayout.java 1KB
字符串获取相关方法.java 1KB
运算符.java 1KB
TestContains.java 1KB
Linkedlist.java 1KB
Object.java 1KB
_03总3.java 1KB
Shape.java 1KB
Complex.java 1KB
BigStudent.java 1KB
Complex.java 1KB
_04输入读数据一个字节数组.java 1KB
随机数.java 1KB
bordLayout.java 1KB
项目学做1.java 1KB
ComplexNumber.java 1KB
_01Collection集合常用方法.java 1KB
Student.java 1KB
_02创建方法.java 1KB
_02字符串的比较常用方法.java 1KB
三角形面积用对象.java 1KB
_01为什么会有字符流.java 1KB
Map遍历.java 1KB
Student.java 1KB
单选按钮.java 1KB
Student1.java 1KB
Student.java 1KB
_06字符缓冲流的特有功能.java 1KB
map.java 1KB
集合到文件.java 1KB
配置文件.java 1KB
Student.java 1KB
字符串的转换相关方法.java 1KB
Properties和IO流结合.java 1KB
Arraylist.java 1KB
_02获取构造方法的对象.java 1KB
_03字符流写数据的5种方法.java 1KB
L1.java 1KB
Shape.java 1KB
_02Throwable方法.java 1KB
_01集合到文件.java 1KB
SmallStudent.java 1KB
_02Collection集合的遍历迭代器.java 1KB
案例字符串中数据排序.java 1KB
样例1.java 1KB
_06字节缓冲流.java 1KB
ListWords.java 1KB
Test11.java 1KB
Test10.java 1KB
集合三种方式遍历.java 1020B
Test.java 1013B
Student.java 986B
编码解码.java 984B
Student.java 984B
Student.java 977B
CentreStudent.java 967B
int和String相互转换.java 967B
_3FuYuZi.java 965B
字符串的分割问题.java 962B
_03通过构造方法的对象来创建对象.java 961B
CentreStudent.java 940B
_06越过泛型检查.java 939B
文件到集合.java 933B
ArraayList集合储存基本数据类型.java 921B
_02Zi.java 918B
Test.java 915B
TreeSet集合概述和特点.java 910B
ArratyList镶套HashMap.java 907B
_01成员内部类.java 896B
Null.java 892B
_01构造方法.java 891B
JLabel标签.java 888B
到原点的距离.java 885B
Box.java 883B
_03输入读数据一个字节.java 880B
_01字符串的构造方法和直接创建.java 878B
_03SimpledateFormat.java 875B
共 360 条
- 1
- 2
- 3
- 4
资源评论
沐知全栈开发
- 粉丝: 5706
- 资源: 5224
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功