readfile.java

来自「java手机程序开发随书光盘源代码」· Java 代码 · 共 44 行

JAVA
44
字号
import javax.microedition.midlet.*;
import java.io.*;

public class ReadFile extends MIDlet{

	InputStream is = null;
	DataInputStream din = null;
	String fileName;

	public ReadFile(){
		fileName = getAppProperty("Test-File-Name");
		is = getClass().getResourceAsStream(fileName);
		din = new DataInputStream(is);
	}

	public void startApp(){
		int l;
		byte[] buffer;
		int c;

		try{
			l = din.available();
			buffer = new byte[l+1];
		}
		catch(Exception ex){ 
			buffer = new byte[10];
		}
        
		try{
			while((c = is.read()) != -1) {
				System.out.print(""+(char)c);
			}
			System.out.println("");
    	}catch(Exception ex){}
	}

	public void pauseApp(){
	}

	public void destroyApp(boolean unconditional){
	}

}

⌨️ 快捷键说明

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