27. publicStringlrcMaker="";//歌词
制作者NN
28. List<LyricStatement>statements=newArrayList<LyricStatement>();
//歌词NN
29. /*
30. *实例化一个歌词数据.歌词数据信息由指定的文件提供.
31. *fileName:指定的歌词文件.
32. */
33.
34. publicLyricReader(StringfileName)throwsIOException{
35. //incasethespaceinthefileNameisreplacedbythe%20
36. FileInputStreamfile=newFileInputStream(URLDecoder.decode(fileN
ame,"UTF-8"));
37. bufferReader=newBufferedReader(newInputStreamReader(file,"GB2
312"));
38.
39. //将文件数据读入内存NN
40. readData();
41. }
42.
43. publicList<LyricStatement>getStatements(){
44. returnstatements;
45. }
46.
47. /*
48. *读取文件中数据至内存.
49. */
50. privatevoidreadData()throwsIOException{
51. statements.clear();
52. StringstrLine;
53. //循环读入所有行NN
54. while(null!=(strLine=bufferReader.readLine())){
55. //判断该行是否为空行NN
56. if("".equals(strLine.trim())){
57. continue;
58. }
59. //判断该行数据是否表示歌名NN
60. if(null==title||"".equals(title.trim())){
61. Patternpattern=Pattern.compile("\\[ti:(.+?)\\]");
62. Matchermatcher=pattern.matcher(strLine);
63. if(matcher.find()){
64. title=matcher.group(1);
65. continue;
66. }