lrc文件解析

public class Lrcget {

/**[code="java"][/code]
* @throws IOException
*/
private static HashMap<Long,String> infos;
private static List<Long>lrctime=new ArrayList<Long>();
public static void read(String file) throws IOException{
infos=new HashMap<Long,String>();
File f = new File(file);
InputStream ins = new FileInputStream(f);
InputStreamReader inr = new InputStreamReader(ins);
BufferedReader reader = new BufferedReader(inr);
String text=null;
while((text=reader.readLine())!=null){
gettext(text);
text=null;
}
Collections.sort(lrctime);
for(int n=0;n<lrctime.size();n++){
System.out.println(lrctime.get(n)+":"+infos.get(lrctime.get(n)));
}
}
public static void gettext(String t){
if(t.startsWith("[ti:")){
System.out.println(t.substring(4, t.length()-1));
}else if(t.startsWith("[ar:")){
System.out.println(t.substring(4, t.length()-1));
}else if(t.startsWith("[al:")){
System.out.println(t.substring(4, t.length()-1));
}else if(t.startsWith("[by:")){
System.out.println(t.substring(4, t.length()-1));
}else if(t.startsWith("[offset")){

}else{
String times[]=t.split("]");
for(int n=0;n<times.length-1;n++){
lrctime.add(gettime(times[n].substring(1)));
infos.put(gettime(times[n].substring(1)), times[times.length-1]);
}
}
}
public static Long gettime(String t){
String times[]=t.split(":", 2);
int m = Integer.parseInt(times[0]);
Double s = Double.parseDouble(times[1]);
return (long) (m*1000*60+s*1000);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String filename="D://七里香.lrc";
try {
read(filename);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
最近写了个lrc文件解析 希望给正在写播放器的朋友有所帮助
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值