猫扑灌水的时候经常发些歌词的帖子不过带有时间的还是过于水了,于是就想写个东东把时间去掉。今天距离这个想法出现已经过了半年了吧,一直没有行动啊。文件操作是在不好玩呐。开始想用c++实现的,后来假期想学java,就写了java的,老实说,这个用java写也没什么意思我想,该是什么时候,才能用GUI重写这个程序呢。骚年呐~~
import java.io.*;
import java.util.Scanner;
public class LrcToNoTime {
static void process(String fileName) throws Exception {
String parentPath= "F:\\weiwei\\Java\\test\\src" ;
File lrc = new File(parentPath,fileName + ".lrc");
FileReader source = new FileReader(lrc);
BufferedReader BRSource = new BufferedReader(source);
String temp = "";
String target = "";
FileWriter fw = new FileWriter(new File(parentPath,fileName+"_new.lrc")) ;
PrintWriter pw = new PrintWriter(fw,true) ;
try {
while ((temp = BRSource.readLine()) != null) {
char[] cTemp = new char[temp.length()];
int k = 0;
int flag = 0;
for (int i = 0; i < temp.length(); i++) {
char tempCh = temp.charAt(i);
if (tempCh == '[') {
flag = -1;
continue;
}
if(flag== -1 &&!(tempCh>='0'&&tempCh<='9')){
flag = 1 ;
}
if (flag == -1 && (tempCh >= '0' && tempCh <= '9')) {
i += 7;
continue;
}
if (tempCh == ']') {
flag = 1;
continue;
}
cTemp[k] = tempCh;
k++;
}
String x=new String(cTemp,0,k) ;
pw.println(x) ;
System.out.println(x) ;
target=target+x+"\n" ;
}
pw.close();
} catch (Exception e) {
} finally {
BRSource.close() ;
}
}
public static void main(String[] args)throws Exception{
String fileName = null;
Scanner sc = new Scanner(System.in) ;
fileName = sc.next();
process(fileName) ;
}
}