zoukankan      html  css  js  c++  java
  • [转]html5音乐播放器

    http://files.cnblogs.com/files/xjyggd/html5music.rar

    import java.io.File;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Map;

    public class directoryTest {
    private static ArrayList<String> filelist = new ArrayList<String>();

    private static Map<String, String> fileMap = new HashMap<String, String>();

    public static void main(String[] args) throws Exception {
    String filePath = "G://music//mp3";
    getFiles(filePath, "mp3");

    StringBuilder stringBuilder = new StringBuilder();

    for(String strFile : filelist)
    {
    String[] strFileSplit = strFile.split("\\");
    String strFileName = strFileSplit[strFileSplit.length-1];
    System.out.println(strFileName);
    if(stringBuilder.length() > 0)
    {
    stringBuilder.append(",");
    }
    stringBuilder.append("{name:'" + strFileName + "',author:'',url:'" + strFile.replace("\","\\") + "'}");
    }
    System.out.println(stringBuilder.toString());
    }
    /*
    * 通过递归得到某一路径下所有的目录及其文件
    */
    static void getFiles(String filePath, String pattern){
    File root = new File(filePath);
    File[] files = root.listFiles();
    for(File file:files){
    if(file.isDirectory()){
    /*
    * 递归调用
    */
    getFiles(file.getAbsolutePath(), pattern);
    //filelist.add(file.getAbsolutePath());
    //System.out.println("显示"+filePath+"下所有子目录及其文件"+file.getAbsolutePath());
    }
    else
    {
    // System.out.println("显示"+filePath+"下所有子目录"+file.getAbsolutePath());
    if (file.getName().contains(pattern))
    {
    //fileMap.put(file.getName(), file.getAbsolutePath());
    filelist.add(file.getAbsolutePath());
    // System.out.println(file.getName() + " " + file.getAbsolutePath());
    }
    }
    }
    }
    }

  • 相关阅读:
    Android安卓 _“Activity"_01+简单的拨号器
    Android安卓 “内部类”
    我的第一天 Andorid “hello_world”
    Android sqlite 创建数据库
    Sqlite(代码 jabc)
    判断网络状态
    Android sqlite(jdbc)
    Android 单机事件的使用
    JAVA内部类(成员.局部.匿名)
    我的第一个Android程序
  • 原文地址:https://www.cnblogs.com/xjyggd/p/4495911.html
Copyright © 2011-2022 走看看