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

📄 motoe1e3.java

📁 J2ME上的一个播放器,可以更换皮肤.开源软件.
💻 JAVA
字号:
package inline.fs;

import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.io.Connector;
import com.motorola.io.file.FileConnection;
import com.motorola.io.file.FileSystemRegistry;

class MotoE1E3 implements FileAccessible
{
    private FileConnection connection;
    private String location;

    MotoE1E3()
    {
    }

    public boolean close()
    {
        boolean result = true;
        
        try
        {
            connection.close();
            connection = null;
        }
        catch(Exception exception)
        {
            System.err.println("Close connection failed: " + exception.getMessage());
            result = false;
        }
        
        return result;
    }

    public boolean open(String filename, int mode)
    {
        boolean result = true;
        
        try
        {
            connection = (FileConnection)Connector.open("file://" + filename, mode);
            location = filename;
        }
        catch(Exception exception)
        {
            connection = null;
            System.err.println("Open connection '" + filename + "' failed: " + exception.getMessage());

            result = false;
        }
       
        return result;
    }
    
    public String[] list()
    {
        String as[] = {};
        if(connection != null)
        {
            Vector vector = new Vector();
            try
            {
                for(Enumeration enumeration = connection.list("*", true); 
                    enumeration.hasMoreElements(); 
                    vector.addElement(enumeration.nextElement()));
            }
            catch(Exception e)
            {
                System.err.println("Can't list the directory: "+e.getMessage());
            }
            as = new String[vector.size()];
            for(int i = 0; i < vector.size(); i++)
                as[i] = location + (String)vector.elementAt(i);
        }
        else
        {
            System.err.println("List failed: connection is null ");
        }
        return as;
    }

    public boolean isDirectory()
    {
        boolean flag = false;
        if(connection != null)
        {
            flag = connection.isDirectory();
        }
        return flag;
    }

    public InputStream openInputStream()
    {
        InputStream inputstream = null;
	if (connection != null)
	{
	    try
	    {
		inputstream = connection.openInputStream();
	    }
	    catch(Exception exception)
	    {
		inputstream = null;
		System.out.println("openInputStream from '" + location + "' failed: " + exception.getMessage());
	    }
	}
        return inputstream;
    }

    public OutputStream openOutputStream()
    {
        OutputStream outputstream = null;
	if (connection != null)
	{
	    try
	    {
		outputstream = connection.openOutputStream();
	    }
	    catch(Exception exception)
	    {
		outputstream = null;
		System.out.println("openOutputStream from '" + location + "' failed: " + exception.getMessage());
	    }
	}
	
	return outputstream;
    }

    public boolean create() throws Exception
    {
        boolean flag = false;
        if(connection != null)
        {
            if(!connection.exists())
	    {	
		connection.create();
                flag = true;
	    }
        }
        return flag;
    }
 
    public boolean delete() throws Exception
    {
        boolean flag = false;
        if(connection != null)
        {
            if(connection.exists())
	    {
		connection.delete();
                flag = true;
	    }
        }
        return flag;
    }

    public boolean exists() throws Exception
    {
        boolean flag = false;
        if(connection != null)
        {
            flag = connection.exists();
        }
        return flag;
    }

    public long fileSize() throws Exception
    {
        long l = -1L;
        if(connection != null)
        {
            l = connection.fileSize();
        }
        return l;
    }
}

⌨️ 快捷键说明

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