[Turn]HTML5 music player

Source: Internet
Author: User

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 ());
}
/*
* Recursively get all the directories and their files under a certain path
*/
static void GetFiles (string filePath, string pattern) {
File root = new file (FilePath);
file[] files = root.listfiles ();
for (File file:files) {
if (File.isdirectory ()) {
/*
* Recursive invocation
*/
GetFiles (File.getabsolutepath (), pattern);
Filelist.add (File.getabsolutepath ());
System.out.println ("Show" +filepath+ "all subdirectories and their files" +file.getabsolutepath ());
}
Else
{
System.out.println ("Show" +filepath+ "All Subdirectories" +file.getabsolutepath ());
if (File.getname (). Contains (pattern))
{
Filemap.put (File.getname (), File.getabsolutepath ());
Filelist.add (File.getabsolutepath ());
System.out.println (File.getname () + "" + File.getabsolutepath ());
}
}
}
}
}

[Turn]HTML5 music player

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.