代码拉取完成,页面将自动刷新
同步操作将从 shengjizhu/e_ink_word_card_2in13低成本平替喵喵机 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package wordsTool;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Test {
static List<String> li=new ArrayList<String>();;
int c = 0;
static void randomarry() throws IOException
{
int num_file = 0;
File file = new File("D:/test.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
while (br.readLine() != null) {
num_file++;
}
br.close();
int[] a= new int[num_file];
for (int i = 0; i < num_file; i++)
{
a[i] = 1234;
}
int index = 0;
while (a[num_file-1] == 1234)
{
int i = (int) (Math.random()*num_file) ;
for (int j = 0; j <= index; j++)
{
if (i == a[j])
{
break;
}
}
a[index] = i;
index++;
}
String str;
int t=0;
File file2 = new File("D:/test.txt");
while(li.size()<num_file) {
BufferedReader br2 = new BufferedReader(new FileReader(file2));
int c=0;
while ((str=br2.readLine())!= null) {
c=c+1;
if(a[t]==c) {
t++;
System.out.println("第"+t+"个:"+str);
li.add(str);
break;
}
}
br2.close();
}
String string ="";
for(String s:li) {
string = string+s+"\r\n";
// System.out.println(s);
}
writeTxt("D:/book.txt", string);
}
public static void writeTxt(String txtPath, String content) {
FileOutputStream fileOutputStream = null;
File file = new File(txtPath);
try {
if (file.exists()) {
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(content.getBytes());
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
File file = new File("D:/src.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String str = "", s = "", st = "";
while ((s = br.readLine()) != null) {
for (int i = 0; i < s.length() - 2; i++) {
if (s.charAt(i) == ' '
&& !(s.charAt(i + 2) <= 122 && s.charAt(i + 2) >= 97 || s.charAt(i + 2) == '.')) {
str += "";
st += "";
} else if (i != 0 && s.charAt(i) == ' ' && s.charAt(i - 1) != ' ' && (s.charAt(i + 1) == 'n'
|| s.charAt(i + 1) == 'a' || s.charAt(i + 1) == 'v' || s.charAt(i + 1) == 'p')) {
str += " ";
st = st + " ";
str += s.charAt(i);
st += s.charAt(i);
} else {
str += s.charAt(i);
st += s.charAt(i);
}
}
str += s.charAt(s.length() - 2);
str += s.charAt(s.length() - 1);
st += s.charAt(s.length() - 2);
st += s.charAt(s.length() - 1);
str += "\r\n";
st += "\r\n";
st = "";
}
br.close();
writeTxt("D:/test.txt", str);
randomarry();
System.out.println("Work done!");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。