⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mlyrics.java~47~

📁 从lrc歌词文件中批量提取歌词
💻 JAVA~47~
字号:
package hy6;
import java.io.*;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class MLyrics {
  String ms;
  boolean end;
  public MLyrics() {
  }
public  void readDir(String _fName,String _fName1)throws IOException {
    File f1=new File(_fName);
    FilenameFilter only=new HYOnlyLrc("lrc");
    if(!f1.isDirectory()){
      System.out.println("You should input a dir!");
      return ;
    }
    String s[]=f1.list(only);

    int i=0;
    for(i=0;i<s.length;i++){
      readFile(_fName+"/"+s[i],_fName1+'/'+s[i]);//注意目录
    }
    return ;
  }
public void readFile(String _fName,String _nfname)throws IOException{
    int beginIndex,endIndex;
    int i;
    String s;
    int len;
    PrintWriter out2 = new PrintWriter(new BufferedWriter(new FileWriter(_nfname)));


    //DataOutputStream out2 = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(_nfname)));

    BufferedReader oBr=new BufferedReader(new FileReader(_fName));
    while((s=oBr.readLine())!=null)
    {//分析
      ms=s;
      end=false;
     while(end==false){
       analyLine(ms);
     }
     //out2.writeUTF(ms);
     if(ms.length()>0)
       out2.println(ms);
    }
    out2.close();
  }
public boolean analyLine(String _s){//分析该行
    int bIndex=0;
    int eIndex=0;
    int len=_s.length();
    int i=0;
    bIndex=0;
    if(len==0)
      return false;
    while((i<len)&&(_s.charAt(i)!='[')){
      i++;
    }
    if(i<len){
      bIndex=i;
    }
    else
    {
      end=true;
      return true;
    }
    while((i<len)&&(_s.charAt(i)!=']')){
      i++;
    }
    if(i==len-1){
      end=true;
      ms="";
      return true;
    }

    if(i<len)
      eIndex=i;
    else
    {
      end=true;
      return true;
    }

    if((bIndex!=eIndex)&&(eIndex!=0)){
      ms=_s.substring(0,bIndex)+_s.substring(eIndex+1,len);
    }
    return true;
  }
public void test(){
    String s="marvin";
    System.out.println(s.substring(0,0));
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -