import java.io.*;import java.awt.*;import java.awt.Graphics;public class FY extends Frame{FileInputStream f=new FileInputStream("The no hug rule.doc");int size=f.available();byte b[]=new byte[size];f.read(b);public void paint(Graphics g){g.drawBytes(b,0,size,100,100);show();f.close();}public static void main(String args[]) throws Exception{new FY();}}
引用第1楼陪你等待奇迹于2006-11-16 14:22发表的:兰色字体的那一个出错了我把他们放到main()里g.drawBytes(b,0,size,100,100);这个又出错了.......
import java.awt.*;import java.io.*;import java.awt.event.*;public class OpenFile extends Frame implements ActionListener{ Button open; TextArea content; FileDialog file; OpenFile(){ open=new Button("Open"); open.addActionListener(this); content=new TextArea(); setLayout(new GridLayout(2,1)); add(content); add(open); setSize(400,400); setVisible(true); } public void actionPerformed(ActionEvent ae){ try{ file=new FileDialog(this,"Open File",FileDialog.LOAD); file.show(); String path=file.getDirectory()+"/"+file.getFile(); DataInputStream fileread=new DataInputStream(new FileInputStream(path)); String data; content.setText(""); while((data=fileread.readLine())!=null){ content.append(data+"\n"); } fileread.close(); }catch(IOException e){ content.append(e.getMessage()); } } public static void main(String args[]){ new OpenFile(); }}
引用第2楼独飞の孤心于2006-11-17 10:15发表的:[code]import java.awt.*;import java.io.*;.......
引用第3楼Optimist于2006-11-17 10:30发表的:这个是java2se吗说什么使用了不同的API