1 private void findMp3Data(File mp3file) { 2 File[] filelist = mp3file.listFiles(); 3 if (filelist != null) { 4 5 for (File n : filelist) { 6 File file = n; 7 if (file.isDirectory()) { 8 findMp3Data(file); 9 } else { 10 // 判断文件后缀名是MP3 11 if (file.getName().endsWith("mp3")) { 12 Mp3data mp3data = new Mp3data(); 13 String mp3name = file.getName(); 14 // 将文件名去掉.mp3后得到的名字 15 mp3data.setMp3_name(mp3name.substring(0, mp3name.length() - ".mp3".length())); 16 mp3data.setMp3_path(file.getAbsolutePath()); 17 18 try { 19 mDao.createOrUpdate(mp3data); 20 } catch (SQLException e) { 21 e.printStackTrace(); 22 } 23 24 } 25 26 } 27 } 28 } 29 }
时间: 2024-11-05 11:01:03