SandiskPlaylist.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package convert_rhythmbox_player_to_sandisk;
  2. // To create the SanDisk playlist file
  3. import java.io.PrintWriter;
  4. // To store the song filenames
  5. import java.util.ArrayList;
  6. // To handle issues creating the SanDisk playlist file
  7. import java.io.FileNotFoundException;
  8. // To store the song files in an ArrayList
  9. import java.io.File;
  10. public class SandiskPlaylist extends Playlist {
  11. private PrintWriter sandiskPlaylistWriter;
  12. SandiskPlaylist(String filename) {
  13. super(filename, "/media/elijah/16GB Rockbo/SD CARD MUSIC/");
  14. try {
  15. sandiskPlaylistWriter = new PrintWriter( getAbsolutePath() );
  16. } catch(FileNotFoundException err) {
  17. System.out.println("SanDisk playlist file could not be created: " + err);
  18. }
  19. }
  20. public void createPlaylistFromSongs(ArrayList<File> songs) {
  21. for (File song : songs) {
  22. // To set the absolute path to each song in the playlist
  23. sandiskPlaylistWriter.println(
  24. "/<microSD1>/SD CARD MUSIC/" + this.getName() + "/" + song.getName()
  25. );
  26. }
  27. // To save/close the SanDisk playlist file
  28. sandiskPlaylistWriter.close();
  29. }
  30. }