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

终于足球项目告一段落,期间学辛苦,无奈与成长都是可写的。
在此期间我让UI折腾的紧,甚至曾经想放弃,终究是坚持下来了。想想在一个小小的屏幕上设计一个UI已经是很痛苦的已经事情,何况在pc上设计,真是佩服死了那些高手们。
最近,时间比较有空,所以把UI修改了下,然后在此基础上+jsr75规范做了个电子书阅读软件。等我设计好了以后,打算开源,大家共同学习,虽然写的不好,各位高手多指教。现在发布一些读取手机目录的方法。
[code]
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();
}

}

[/code]

[code]
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;

}

}
[/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值