MediaLibrary.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:boomer-tuner 作者:
@SuppressWarnings("unchecked")
private void readSerializedLibrary(final File location) {
    try {
        FileInputStream fileIn = new FileInputStream(location);
        ObjectInputStream in = new ObjectInputStream(fileIn);
        songs = FXCollections.observableList((List<Song>) in.readObject());
        playlists = FXCollections.observableList((List<Playlist>) in.readObject());
        videos = FXCollections.observableList((List<Video>) in.readObject());
        images = FXCollections.observableList((List<Image>) in.readObject());
        for (Song song : songs) {
            if (!artists.contains(song.getArtist())) {
                artists.add(song.getArtist());
            }
            if (!albums.contains(song.getAlbum())) {
                albums.add(song.getAlbum());
            }
        }

        Collections.sort(albums, Comparator.comparing(Album::getName));
        Collections.sort(artists, Comparator.comparing(Artist::getName));
        Collections.sort(songs, Comparator.comparing(Song::getTitle));
        Collections.sort(images, Comparator.comparing(Image::getName));

        in.close();
        fileIn.close();
    } catch (IOException | ClassNotFoundException e) {
        e.printStackTrace();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号