lrc资料解析

lrc文件解析
public class Lrcget {

/**


* @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文件解析 希望给正在写播放器的朋友有所帮助