Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22292
  • 博文数量: 12
  • 博客积分: 520
  • 博客等级: 中士
  • 技术积分: 150
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-03 15:32
文章分类

全部博文(12)

文章存档

2011年(1)

2009年(11)

我的朋友
最近访客

分类: Java

2009-04-08 13:58:38

1. 遍历手机的根目录
 

Enumeration enumer = FileSystemRegistry.listRoots();
             String root = null;
             while(enumer.hasMoreElements()){
                 root = (String)enumer.nextElement();
                 append(root+"\n");
             }

2. 访问指定路径的文件

FileConnection fconn = (FileConnection)Connector.open("file:///存储卡/dialer.txt",Connector.READ);
         if (fconn.exists()){
                 DataInputStream dataIn = fconn.openDataInputStream();
                 int fileSize = (int)fconn.fileSize();
                 byte[] data = new byte[fileSize];
                 dataIn.read(data,0,fileSize);
                 append(new String(data));
             }else
                 append("file:///存储卡/dialer.txt not exist!");
         fconn.close();

阅读(439) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~