用j2me设计一个手机电子书阅读软件

终于足球项目告一段落,期间学辛苦,无奈与成长都是可写的。

在此期间我让UI折腾的紧,甚至曾经想放弃,终究是坚持下来了。想想在一个小小的屏幕上设计一个UI已经是很痛苦的已经事情,何况在pc上设计,真是佩服死了那些高手们。

最近,时间比较有空,所以把UI修改了下,然后在此基础上+jsr75规范做了个电子书阅读软件。等我设计好了以后,打算开源,大家共同学习,虽然写的不好,各位高手多指教。现在发布一些读取手机目录的方法。

package org.pook.file;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.io.file.FileSystemRegistry;

import org.pook.log.Log;

/**
 * <b>类名:BookFileImpl.java</b> </br> 
 * 编写日期: 2006-10-12 <br/>
 * 程序功能描述: <br/>
 * Demo: <br/>
 * Bug: <br/>
 * 
 * 程序变更日期 :<br/> 
 * 变更作者 :<br/> 
 * 变更说明 :<br/>
 * 
 * @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
 */
public class BookFileImpl implements BookFile {
	private static Log log = Log.getLog("BookFileImpl");
	
	FileConnection conn = null;
	
	BookFileImpl(String url){
		try {
		    conn = (FileConnection) Connector.open( url, Connector.READ);

		   
		}catch( IOException e ){
		    e.printStackTrace();
		}
		catch( SecurityException e ){
		   e.printStackTrace();
		}

	}
	
	
	public Vector listName() throws IOException {
		 
		Vector vc = null;
		 if( conn.isDirectory() ){
		        Enumeration names = conn.list();
		        vc = new Vector();     
		        while( names.hasMoreElements() ){
		        	vc.addElement(names.nextElement());
		            
		        }
		        return vc;
		    } else {
		        return null;
		  }
	}

	public String read() throws IOException {
	      return null;
	}

	public boolean isFile() {
		
		if(conn.isDirectory())
			return false;
		else
			return true;
	}


	public String getFilePath() {
		checkConn();
		return conn.getPath();
	}


	private void checkConn() {
		if(conn == null)
			throw new NullPointerException("文件资源不存在!");
		
	}


	public String getFileName() {
		checkConn();
		return conn.getName();
	}


	public void close() {
		if(conn != null)
			try {
				conn.close();
			} catch (IOException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
			}
		
	}
package org.pook.file;

import java.util.Enumeration;
import java.util.Vector;

import javax.microedition.io.file.FileSystemRegistry;

import org.pook.log.Log;

/**
 * <b>类名:BookFileManager.java</b> </br> 编写日期: 2006-10-12 <br/> 程序功能描述: <br/>
 * Demo: <br/> Bug: <br/>
 * 
 * 程序变更日期 :<br/> 变更作者 :<br/> 变更说明 :<br/>
 * 
 * @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
 */
public class BookFileManager {
	private static Log log = Log.getLog("BookFileManager");
	public static boolean available() {
		String version = System
				.getProperty("microedition.io.file.FileConnection.version");

		if (version != null) {
			return true;
		} else {
			return false;
		}

	}

	public static BookFile openBookFile(String url) {
		return new BookFileImpl(url);
	}
	
	
	 

	public static Vector listRoots() {

	 
		Vector vc = null;

		Enumeration names = FileSystemRegistry.listRoots();
		 
		vc = new Vector();

		while (names.hasMoreElements()) {		
			vc.addElement(names.nextElement());
			//log.debug(names.nextElement());
		}
		 
		return vc;

	}

}