무선 모바일 자바 프로그래밍을 통한 logbook의 구현
본 자료는 4페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
해당 자료는 4페이지 까지만 미리보기를 제공합니다.
4페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

무선 모바일 자바 프로그래밍을 통한 logbook의 구현에 대한 보고서 자료입니다.

목차

1. 개요

2. 기본 이해사항

3. 구현 요소

4. 프로그램 동작원리

5. 실제구동

6. 참고서적

7. 소스코드 첨부

본문내용

저장되어 있음
id = _id;
init_log(rec);
}
public LogFile(long timer, String user, String description){ // 생성자
this.timer = timer;
this.user = user;
this.description = description;
}
public void init_log(byte[] rec){ // 레코드를 파싱해서 가져옴
ByteArrayInputStream bais = new ByteArrayInputStream(rec);
DataInputStream dis = new DataInputStream(bais);
try
{
timer = dis.readLong();
user = dis.readUTF();
description = dis.readUTF();
}catch(Exception e){}
}
public byte[] toBytes(){ // record store에 저장하기 위해 byte array로 변환한다.
byte data[] = null;
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeLong(timer);
dos.writeUTF(user);
dos.writeUTF(description);
data = baos.toByteArray();
baos.close();
dos.close();
}catch(Exception e){}
return data;
}
public String getTimeString(){ // 시간을 표현형태로 만들어줌
StringBuffer sb = new StringBuffer();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(timer));
sb.append(cal.get(Calendar.MONTH)+1).append(\"/\");
sb.append(cal.get(Calendar.DAY_OF_MONTH)).append(\"/\");
sb.append(cal.get(Calendar.YEAR)).append(\" \");
sb.append(cal.get(Calendar.HOUR_OF_DAY)).append(\":\");
if(cal.get(Calendar.MINUTE) < 10) sb.append(0);
sb.append(cal.get(Calendar.MINUTE));
return sb.toString();
}
public int getID(){return id;}
public void setID(int id){this.id = id;}
public long getTimer(){return timer;}
public void setTimer(long timer){this.timer = timer;}
public String getUser(){return user;}
public void setUser(String user){this.user = user;}
public String getDescription(){return description;}
public void setDescription(String description){this.description = description;}
}
/***************************************
* MAKEDB.JAVA *
***************************************/
import java.io.*;
import java.util.*;
import javax.microedition.rms.*;
public class makeDB{
RecordStore rs = null; // Mobile DB를 위한 RMI 생성
public makeDB(){
try
{
rs = RecordStore.openRecordStore(\"logfile\", true); // DB파일을 연다.
}catch(Exception e){
System.out.println(\"Error : \" + e.getMessage());
}
}
public void close(){
if(rs != null){
try
{
rs.closeRecordStore();
}catch(Exception e){}
}
}
public boolean save_log(LogFile lf){ // user이름과 설명을 저장한다.
if(rs == null) return false; // 만일 못열면 error
boolean success = false;
try
{
byte data[] = lf.toBytes(); // 바이트 단위로 바꾼다.( toBytes() 함수이용 )
int id = lf.getID();
if(id == 0){ // 새로운 레코드 생성
id = rs.addRecord(data, 0, data.length); // 레코드 추가
lf.setID(id);
}
success = true;
}catch(Exception e){
System.out.println(\"Error : \" + e.getMessage());
}
return success;
}
public Vector retrieveAll(){ // 저장된 모든 log를 가져온다.(offline)
RecordEnumeration re = null;
Vector logs = new Vector();
try
{
re = rs.enumerateRecords(null,null,false);
while(re.hasNextElement()){ // 데이터가 더 있으면
int rec_id = re.nextRecordId(); // 다음 데이터 ID
// vector log에 현재 DB에 있는 데이터를 저장한다.
logs.addElement(new LogFile(rec_id, rs.getRecord(rec_id)));
}
}catch(Exception e){}
finally
{
if(re != null) re.destroy();
}
return logs;
}
}
  • 가격1,500
  • 페이지수14페이지
  • 등록일2004.01.03
  • 저작시기2004.01
  • 파일형식한글(hwp)
  • 자료번호#241494
본 자료는 최근 2주간 다운받은 회원이 없습니다.
다운로드 장바구니