将歌词里的时间去掉

猫扑灌水的时候经常发些歌词的帖子不过带有时间的还是过于水了,于是就想写个东东把时间去掉。今天距离这个想法出现已经过了半年了吧,一直没有行动啊。文件操作是在不好玩呐。开始想用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) ; 
	}
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值