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 @ 2023-03-01 20:15  呦吼吼吼  阅读(24)  评论(0)    收藏  举报