java去除第三个 号_求java源吗 以下文本删除第一行;还有删除“;”“%”。 每一行前加N开头4位序号...

展开全部

修改结果输出到桌面

代码:

aa9903247ad6e0ae49f8fb1fc76a7998.png

package com.hmall;

/**

* @ClassName Test3

* @Description TODO

* @Author dell

* @Date 2019/6/25 16:05

* @Version 1.0

**/

import java.io.*;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.Calendar;

import java.util.List;

public class Test3 {

private static String autoGenericCode(String code, int num) {

String result;

result = String.format("%0" + num + "d", Integer.parseInt(code));

return result;

}

public static void main(String args[]) throws Exception {

//下面传入自己桌面的路径:单斜杠62616964757a686964616fe4b893e5b19e31333431356564要转义为双斜杠

BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\dell\\Desktop\\test.txt"));

List list = new ArrayList();

int i = 0;

while (true) {

String line = br.readLine();

if (line == null) {

break;

}

if (i != 0) {

String result = line.replaceAll(";", "").replaceAll("%", "");

list.add("N" + autoGenericCode(String.valueOf(i), 3) + "0 " + result);

}

i = i + 1;

}

File f = new File("C:\\Users\\dell\\Desktop\\result.txt");

BufferedWriter bw;

try {

bw = new BufferedWriter(new FileWriter(f));

for (String s : list) {

bw.write(s);

bw.newLine();

}

bw.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页