2023/2/27每日总结

以下为今日课上所写代码
package Text;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*关于文件导入并找出最长的接龙单词链:
* 1.先学习利用java的io流将text文件数据导入
* 判断文件是否存在
* 2.将导入的文件数据存在一个字符串数组中:List<String>list
* 需要将其全部转化为小写?
*
* 3.
* */

public class Piao {
public static void FileReaderToMakeGroup(List<String> list, String file) {
File file1 = new File(file);
try {
if (!file1.exists()) {
System.out.println("文件不存在!");
file1.createNewFile();
}
PrintWriter pw = new PrintWriter(file1);

int leng = list.size();
for (int i = 0; i < leng; ++i) {
String str = list.get(i);
if (str.charAt(str.length() - 1) == '-' || str.charAt(str.length() - 1) == '—')
str = str.substring(0, str.length() - 1);
pw.println(str);
}

pw.close();
} catch (Exception e) {
return;
}
}

//处理输入文件,将处理的文件导入成单词数组
public static List<String> makeDealWith(String file) {
List<String> list = new ArrayList<String>();
File file1 = new File(file);
Scanner sc = null;
try {
if (!file1.exists()) {
file1.createNewFile();
}


} catch (IOException e) {
e.printStackTrace();
}


}

}
posted @   呦吼吼吼  阅读(17)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· winform 绘制太阳,地球,月球 运作规律
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示