張生工作室
一切皆有可能
BlogJava
::
首頁
::
新隨筆
::
聯(lián)系
::
聚合
::
管理
::
24 隨筆 :: 3 文章 :: 11 評(píng)論 :: 0 Trackbacks
<
2007年9月
>
日
一
二
三
四
五
六
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(4)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年12月 (3)
2008年11月 (9)
2008年7月 (1)
2008年5月 (1)
2007年9月 (10)
文章檔案
2011年3月 (1)
2008年11月 (1)
2007年12月 (1)
相冊(cè)
個(gè)人影集
好友鏈接
我的C#博管
我的百度博客
搜索
最新評(píng)論
1.?re: j2me模擬短信
我同意
--15170987588
2.?re: 求助(邊位仁兄有pointbase數(shù)據(jù)庫的,麻煩傳一份給我,急)
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--ufo
3.?re: MathLab使用
看不明白
--天涯浪子
4.?re: MathLab使用[未登錄]
請(qǐng)問要表示以(-0.5)為底的指數(shù)要怎么表示啊
--小小
5.?re: MathLab使用
快速入門,方便大家...謝謝..
--292939760
閱讀排行榜
1.?第四章 管理信息系統(tǒng)規(guī)劃與開發(fā)方法(6096)
2.?MathLab使用(2207)
3.?數(shù)學(xué)建模公車表(1689)
4.?數(shù)學(xué)建模公車表二(974)
5.?數(shù)學(xué)建模地鐵信息(948)
評(píng)論排行榜
1.?MathLab使用(3)
2.?數(shù)學(xué)建模公車表(3)
3.?數(shù)學(xué)建模地鐵信息(2)
4.?數(shù)學(xué)建模公車表二(1)
5.?求助(邊位仁兄有pointbase數(shù)據(jù)庫的,麻煩傳一份給我,急)(1)
一個(gè)涉及rms查詢的簡單例子
/**/
/*
* ComplexFind.java
*
* Created on 2007年9月10日, 下午8:31
*/
import
java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream;
import
java.io.DataInputStream;
import
java.io.DataOutputStream;
import
javax.microedition.midlet.
*
;
import
javax.microedition.lcdui.
*
;
import
javax.microedition.rms.RecordEnumeration;
import
javax.microedition.rms.RecordFilter;
import
javax.microedition.rms.RecordStore;
import
javax.microedition.rms.RecordStoreException;
/** */
/**
*
*
@author
Administrator
*
@version
*/
public
class
ComplexFind
extends
MIDlet
implements
javax.microedition.lcdui.CommandListener
{
private
Display display;
private
Form form;
private
Alert alert;
private
Command exit;
private
Command start;
private
RecordStore recordstore
=
null
;
private
RecordEnumeration recordenumeration
=
null
;
private
Filter filter;
public
ComplexFind()
{
display
=
Display.getDisplay(
this
);
exit
=
new
Command(
"
Exit
"
,Command.SCREEN,
1
);
start
=
new
Command(
"
Start
"
,Command.SCREEN,
1
);
form
=
new
Form(
"
查詢復(fù)雜數(shù)據(jù)
"
);
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(
this
);
}
public
void
startApp()
{
display.setCurrent(form);
}
public
void
pauseApp()
{
}
public
void
destroyApp(
boolean
unconditional)
{
}
public
void
commandAction(Command command, Displayable displayable)
{
if
(command
==
exit)
{
destroyApp(
false
);
notifyDestroyed();
}
else
if
(command
==
start)
{
try
{
recordstore
=
RecordStore.openRecordStore(
"
myRecordStore
"
,
true
);
}
catch
(RecordStoreException ex)
{
alert
=
new
Alert(
"
Error
"
,ex.toString(),
null
,AlertType.WARNING);
ex.printStackTrace();
}
try
{
byte
[] outputRecord
=
null
;
String[] outputString
=
{
"
Adam
"
,
"
張生工作室
"
,
"
Mary
"
,
"
你好
"
,
"
張三
"
,
"
有鬼魂
"
}
;
int
outputInteger[]
=
{
15
,
10
,
5
,
78
,
23
,
32
}
;
ByteArrayOutputStream outputStream
=
new
ByteArrayOutputStream();
DataOutputStream outputDataStream
=
new
DataOutputStream(outputStream);
for
(
int
i
=
0
; i
<
outputString.length;i
++
)
{
outputDataStream.writeUTF(outputString[i]);
outputDataStream.writeInt(outputInteger[i]);
outputDataStream.flush();
outputRecord
=
outputStream.toByteArray();
recordstore.addRecord(outputRecord,
0
,outputRecord.length);
outputStream.reset();
}
outputStream.close();
outputDataStream.close();
}
catch
(Exception e)
{
alert
=
new
Alert(
"
Error
"
,e.toString(),
null
,AlertType.ERROR);
}
try
{
String inputString;
byte
[] byteInputData
=
new
byte
[
300
];
ByteArrayInputStream inputStream
=
new
ByteArrayInputStream(byteInputData);
DataInputStream inputDataStream
=
new
DataInputStream(inputStream);
if
(recordstore.getNumRecords()
>
0
)
{
filter
=
new
Filter(
"
三
"
);
recordenumeration
=
recordstore.enumerateRecords(filter,
null
,
false
);
while
(
this
.recordenumeration.hasNextElement())
{
recordstore.getRecord(
this
.recordenumeration.nextRecordId(),byteInputData,
0
);
inputString
=
inputDataStream.readUTF()
+
"
"
+
inputDataStream.readInt();
alert
=
new
Alert(
"
Reading
"
,inputString,
null
,AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
inputStream.close();
}
}
catch
(Exception e)
{
}
try
{
this
.recordstore.closeRecordStore();
}
catch
(Exception e)
{
}
if
(
this
.recordstore.listRecordStores()
!=
null
)
try
{
RecordStore.deleteRecordStore(
"
myRecordStore
"
);
filter.filterClose();
this
.recordenumeration.destroy();
}
catch
(Exception e)
{
}
}
}
class
Filter
implements
RecordFilter
{
private
String search
=
null
;
private
ByteArrayInputStream inputstream
=
null
;
private
DataInputStream datainputstream
=
null
;
public
Filter(String str)
{
this
.search
=
str;
}
public
boolean
matches(
byte
[] b)
{
String string
=
null
;
try
{
String stra
=
b.toString();
inputstream
=
new
ByteArrayInputStream(b);
datainputstream
=
new
DataInputStream(inputstream);
string
=
datainputstream.readUTF();
}
catch
(Exception e)
{
return
false
;
}
if
(string
!=
null
&&
string.indexOf(
this
.search)
!=-
1
)
{
return
true
;
}
else
return
false
;
}
public
void
filterClose()
{
try
{
if
(inputstream
!=
null
)
{
inputstream.close();
}
if
(datainputstream
!=
null
)
{
datainputstream.close();
}
}
catch
(Exception e)
{
}
}
}
}
張生工作室
posted on 2007-09-10 22:22
張生工作室
閱讀(422)
評(píng)論(0)
編輯
收藏
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © 張生工作室
主站蜘蛛池模板:
嘉峪关市
|
长丰县
|
海口市
|
郎溪县
|
彭州市
|
抚顺县
|
汉沽区
|
新郑市
|
曲周县
|
太和县
|
龙山县
|
遂溪县
|
雅安市
|
延川县
|
高台县
|
彰化市
|
莎车县
|
北川
|
永寿县
|
昭觉县
|
镇平县
|
文成县
|
峨边
|
平塘县
|
铅山县
|
望都县
|
兰州市
|
苍山县
|
东乡
|
武穴市
|
台南县
|
温州市
|
大冶市
|
西宁市
|
永吉县
|
东阿县
|
沈丘县
|
永新县
|
信阳市
|
寿光市
|
明光市
|