java大作业报告模板 下载本文

内容发布更新时间 : 2024/5/3 13:15:59星期一 下面是文章的全部内容请认真阅读。

b7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { byte a[]=new byte[1000]; int i;

int findpersion=-1;

String str=null; try{

FileInputStream fis=new FileInputStream(\ i=fis.read(a,0,1000); try{

str=new String(a,0,i); }

catch(Exception ee){

System.out.println(\编码没有被发现\ }

fis.close(); }

catch(FileNotFoundException e1){

System.out.println(\ }

catch(IOException e1){ e1.printStackTrace(); }

jArea.setText(str); } });

j4.add(jll1); j4.add(jll2); j4.add(jtt); j4.add(jArea);

j4.add(b6); j4.add(b7);

b4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

t1.setText(null);t2.setText(null);t4.setText(null); t5.setText(null);t6.setText(null); r1.setSelected(false);

r2.setSelected(false); } });

b5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) { String s=new String(); if(r1. isSelected() ){

s=t1.getText()+\\

t6.getText()+\ }else {

s=t1.getText()+\ r2.getText()+\\ }

s=s+\

byte a[]=s.getBytes(); try{

FileOutputStream fos=new FileOutputStream(\ fos.write(a);

JOptionPane.showMessageDialog(null, \信息写入成功\

\提示\ fos.close(); number++;

char char1=(char)number;

FileWriter fw=new FileWriter(\

fw.write(char1); fw.close(); }

catch(IOException e1){ e1.printStackTrace(); }

} });

l1=new JLabel(\学生信息录入\

l1.setFont(new Font(\ l2=new JLabel(\学号\

l2.setFont(new Font(\ l3=new JLabel(\姓名\

l3.setFont(new Font(\ l4=new JLabel(\专业\

l4.setFont(new Font(\ l5=new JLabel(\身份证号\

l5.setFont(new Font(\ l6=new JLabel(\班级\

l6.setFont(new Font(\ l7=new JLabel(\性别\

l7.setFont(new Font(\

j1.add(b1); j1.add(b3); j1.add(b2);

l1.setBounds(200,20,300,30); b4.setBounds(170,340,65,30); b5.setBounds(360,340,65,30); l2.setBounds(80, 130, 80, 30); t1.setBounds(160, 130, 80, 25); l3.setBounds( 300, 130, 80, 25); t2.setBounds(380, 130, 80, 25); l7.setBounds(80, 180, 80, 30); //t3.setBounds(160, 180, 80, 25); l5.setBounds( 300, 180, 80, 25); t4.setBounds(380, 180, 130, 25); l4.setBounds(80, 230, 80, 25); t6.setBounds(160, 230, 125, 25); l6.setBounds(300, 230, 80, 25); t5.setBounds(380, 230, 80, 25); r1.setBounds(160,180,40,25 ); r2.setBounds(200,180,40,25 );

j2.add(l1);

j2.add(b4); j2.add(b5); j2.add(l2); j2.add(t1); j2.add(l3); j2.add(t2); j2.add(l7); //j2.add(t3); j2.add(r1); j2.add(r2); j2.add(l5); j2.add(t4); j2.add(l4); j2.add(t6); j2.add(l6); j2.add(t5);

jb1=new JButton(\查询\ jb2=new JButton(\保存\

jb1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileReader fr = null; try {

fr = new FileReader(\ } catch (FileNotFoundException e1) {

e1.printStackTrace(); }

try {

number1=(int)fr.read(); } catch (IOException e1) {

// TODO Auto-generated catch block e1.printStackTrace(); } try {

fr.close();

} catch (IOException e1) {

// TODO Auto-generated catch block e1.printStackTrace(); }

if (number1!=-1) number=number1;

System.out.println(number);

if(!jt1.getText().trim().equals(\ filefind(); }

else{

JOptionPane.showMessageDialog(null,\请输入需要查询学生的学号\

\温馨提示\ } }

public void filefind() { byte a[]=new byte[1000]; int i;

int findpersion=-1;

String str=null; try{

FileInputStream fis=new FileInputStream(\

i=fis.read(a,0,1000); try{

str=new String(a,0,i); }

catch(Exception ee){

System.out.println(\编码没有被发现\ }

fis.close(); }

catch(FileNotFoundException e){

System.out.println(\ }

catch(IOException e){ e.printStackTrace(); }

System.out.println(\ System.out.println(str);

System.out.println(\

String[] findstring=new String[number]; String[] sstr=new String[5]; findstring=str.split(\ String sfind=null;