⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelexception.java

📁 《j2me开发精解〉(詹健飞)CD-rom附带源码。用netbeans
💻 JAVA
字号:
package com.j2medev.ch5.post.share;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class ModelException extends Exception {
    
    public static final byte CAUSE_GENERAL = 0;//通用错误
    public static final byte CAUSE_IO_ERROR = 1;//IO错误
    public static final byte CAUSE_CANNOT_FIND_ARTICLE = 2;//找不到指定文章
    //这里可以自由定义一些代表了错误类型的常量
    private int causeCode = CAUSE_GENERAL;

    public ModelException(int causeCode) {
        this.causeCode = causeCode;
        return;
    }

    public int getCauseCode() {
        return causeCode;
    } 

    public void serialize(DataOutputStream dataStream) 
            throws ApplicationException {
        try {
            dataStream.writeInt(causeCode);
            return;
        } catch (IOException ioe) {
            throw new ApplicationException(ioe);
        } 
    } 

    public static ModelException deserialize(DataInputStream dataStream) 
            throws ApplicationException {
        try {
            return new ModelException(dataStream.readInt());
        } catch (IOException ioe) {
            throw new ApplicationException(ioe);
        } 
    } 

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -