请帮忙检查下访问存储卡的代码

zwtchy123 zwtchy123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1、建目录 zhj目录已有
String strDirName = System.getProperty("fileconn.dir.memorycard") + "zhj/";
FileConnection fConn = null;
try {
fConn = (FileConnection)Connector.open(strDirName,Connector.READ_WRITE );
if(!fConn.exists())
fConn.create();
}....
2写文件
String strFileName = System.getProperty("fileconn.dir.memorycard") + "zhj/test.txt";
FileConnection fConn = null;
OutputStream out = null;
try {
fConn = (FileConnection)Connector.open(strFileName,Connector.READ_WRITE);
if(!fConn.exists()){
fConn.create();
}
out = fConn.openOutputStream();
out.write("abcdef科技大厦1楼".getBytes("UTF-8"));
out.flush();
}....
3读文件
String strFileName = System.getProperty("fileconn.dir.memorycard") + "zhj/test.txt";
FileConnection fConn = null;
InputStream in = null;
try {
fConn = (FileConnection)Connector.open(strFileName, Connector.READ);
in = fConn.openInputStream();
byte buf[] = new byte[(int)fConn.fileSize()];
in.read(buf);
String str = new String(buf,"UTF-8");
}....
报错,请大虾给看一下!!!
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
zwtchy123
J2ME 13,096 成员 26,491 内容