}
catch (Exception e) { }
finally { }
return content;
try {if (reader != null)reader.close();} catch (Exception e) {} try {if (in != null)in.close();} catch (Exception e) {} //e.printStackTrace();
System.out.println(myTime.getNowTime());
System.out.println(\找不到《\ + file.getName() + \》歌
词文件!\);
protected static LyricsContent doFilter(String value) {
value = value.replaceAll(\,\『\).replaceAll(\,\』value = value.replaceAll(\,\);
value = value.replaceAll(\『\,\).replaceAll(\』String[] lines = value.split(\); String line, key, nextKey, text = null; LyricsContent content = new LyricsContent(); ArrayList list = new ArrayList(); HashMap map = new HashMap(); content.setContent(list); content.setMap(map);
StringBuffer contentText = new StringBuffer(\); int index = 0;
for (int i = 0; i < lines.length; i++) {
line = lines[i];
if (line.startsWith(\)) {
key = line.substring(1, line.indexOf(\, 0)); if (key.matches(\)) {
text = line.substring(line.lastIndexOf(\) + 1, list.add(index, text);
key = line.substring(0, line.lastIndexOf(\) + 1); while ((nextKey = key.substring(0, key.indexOf(\, 0) +
key = key.substring(key.indexOf(\, 0) + 1, nextKey = nextKey.substring(1, 6);
\).replaceAll(\,\∶\);
\,\).replaceAll(\∶\,\);
line.length());
1)).length() > 0) { key.length());
contentText.append(\ + nextKey + \);
- 46 -
}
}
}
}
}
}
map.put(nextKey, new Integer(index));
contentText.append(text + \); index++;
else { }
if (key.toLowerCase().startsWith(\)) { }
else if (key.toLowerCase().startsWith(\)) { }
content.setSinger(key.substring(3, key.length())); contentText.append(\ + content.getSinger() + content.setName(key.substring(3, key.length())); contentText.append(\ + content.getName() + \);
\);
content.setText(contentText.toString()); return content;
LyricsContent.java
package player.lyrics;
import java.util.ArrayList; import java.util.HashMap;
public class LyricsContent {
public void setMap(HashMap map) { }
this.map = map;
public ArrayList getContent() { }
return content;
private ArrayList content = null; private HashMap map = null; private String name = \; private String singer = \; private String text = \;
- 47 -
public void setContent(ArrayList content) { }
public void setName(String name) { }
public void setSinger(String singer) { }
public void setText(String text) { }
public HashMap getMap() { }
public String getName() { }
public String getSinger() { }
public String getText() { }
public int rowCount() { }
public int getIndex(String key) { }
public String getContent(int row) { }
return (String) content.get(row);
return ((Integer) map.get(key)).intValue(); return content.size(); return text; return singer; return name; return map; this.text = text; this.singer = singer; this.name = name; this.content = content;
- 48 -
}
public String getContent(String key) { }
return (String) content.get(((Integer) map.get(key)).intValue());
LyricsContents.java
package player.lyrics;
import java.util.*;
public class LyricsContents { }
public int getSize() { }
return list.size();
public int indexOf(LyricsContent content) { }
return list.indexOf(content); public LyricsContent get(int index) { }
return (LyricsContent) list.get(index); public void removeAll() { }
list.removeAll(list);
public void remove(LyricsContent content) { }
list.remove(content); public void remove(int index) { }
list.remove(index);
public void add(LyricsContent content) { }
list.add(content);
private ArrayList list = new ArrayList();
LyricsDownLoedListener.java
package player.lyrics;
- 49 -
public interface LyricsDownLoedListener { }
public void lyricsDowned(LyricsContents contents);
LyricsHunter.java
package player.lyrics;
import java.io.*;
import java.util.ArrayList; import java.util.regex.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
public class LyricsHunter extends Thread {
public void run() {
PostMethod postMethod = new PostMethod(\); InputStream in = null;
BufferedReader reader = null;
StringBuffer content = new StringBuffer(\); try {
public LyricsHunter(String muiscName) { }
this.muiscName = muiscName;
httpClient.getHostConfiguration().setHost(\, 80, public void removeLyricsDownLoadListener(LyricsDownLoedListener listener) { }
listeners.remove(listener);
public void addLyricsDownLoadListener(LyricsDownLoedListener listener) { }
listeners.add(listener);
public static void main(String[] args) { }
new LyricsHunter(\); private HttpClient httpClient = new HttpClient(); private String muiscName = null;
private ArrayList listeners = new ArrayList();
\);
- 50 -