⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listtofile.java

📁 基于JMF实现的MediaPlayer.
💻 JAVA
字号:
/*
 * ListToFile.java
 *
 * Created on 2006年5月10日, 下午8:47
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package media;
import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
/**
 *
 * @author freezing
 */
public class ListToFile implements Serializable
{
    private Vector temp;
    private File file;
    /** Creates a new instance of ListToFile */
    public ListToFile(Vector m) {
        file=new File("MusicInfo.ini");
        temp=m;
    }
    private void write()
    {
        try{
        FileOutputStream fileOut=new FileOutputStream("MusicInfo.ini");
                 //创建对象输出流
	ObjectOutputStream objectOut=new ObjectOutputStream(fileOut);
                //将音乐列表写入到文件中
	objectOut.writeObject(temp);
        JOptionPane.showMessageDialog(null, "音乐列表已经保存!", "信息", JOptionPane.INFORMATION_MESSAGE);
        }catch(IOException e)
        {
            JOptionPane.showMessageDialog(null, "无法保存音乐列表!", "警告!", JOptionPane.ERROR_MESSAGE); 
        }
    }
    public void save()
    {
         try{
            if(!file.exists())
            {
                if(file.createNewFile())
		{
                    this.write();
                }
            }
            else
            {
                 this.write();
                // JOptionPane.showMessageDialog(null, "文件已经存在!", "警告!", JOptionPane.ERROR_MESSAGE); 
            }
        }catch(IOException e)
        {
            System.out.println(e.getMessage());
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -