会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133818个问题
JAVA 全系列/第九阶段:SpringBoot与MybatisPlus/MybatisPlus(旧) 10816楼
JAVA 全系列/第九阶段:SpringBoot与MybatisPlus/MybatisPlus(旧) 10818楼

老师帮看一下 我的按钮   “是”跳转图片不成功

<!DOCTYPE html>

<html>

 <head>

  <meta charset="utf-8">

  <title></title>

  

  <style>

   

   body{

    

    background-image: url(img/bjsky.jpg);

    

    background-repeat:no-repeat ;

    

    background-size: 1600px 800px;

     

   }

   a{

    

    font-size: 25px;

    

    color: #ffffff;

    

   }

   .div1{

    

    width: 300px;

    

    height: 200px;

    

    background-color: gray;

    

    text-align: center;

    

   }

   input{

    

    width: 40px;

    

    height: 30px;

    

   }

   

  </style>

  <script>

  

  var i=-1;

   function changebc(){

    

    var arr=['bjsky.jpg','mayun.jpg','simple.jpg','sxt.jpg','zgc.jpg'];

    

    

    if(i<arr.length-1){

     

     i++;

    }else{

     i=0;

     

    }

    

    document.body.style.backgroundImage="url(img/"+arr[i]+")"

    

   }

   function chengove(){

    //获得div对象

    

    var div = document.getElementById("div_1");

    

    div.style.marginTop=Math.random()*500+"px";

    

    div.style.marginLeft=Math.random()*800+"px";

    

    

    

   }

   function changeclk(){

    

    document.body.style.backgroundImage="url(img/1.jpg)";

    

    //设置当前div隐藏

    document.getElementById("div_1").style.display="none";

    

   }

   

   

  </script>

  

 </head>

 <body>

  

  < a href="javascript:changebc()">点击更换主题</ a>

  

  <div class="div1" id="div_1">

   

   <h3>我是不是你的小可爱</h3>

   

   <input type="button" value="是" onclick="changeclk" />

   

   <input type="button" value="否"   onmouseover="chengove()"/>

   

  </div>

  

  

 </body>

</html>


JAVA 全系列/第五阶段:网页编程和设计/Javascript 语言(旧) 10819楼
JAVA 全系列/第十阶段:权限控制与安全认证/Spring Security(旧) 10820楼
Python 全系列/第一阶段:AI驱动的Python编程/编程基本概念 10822楼
JAVA 全系列/第七阶段:项目管理与SSM框架/Spring旧 10824楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 10825楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/面向对象详解和JVM底层内存分析 10826楼

public void start() {
    Menu menu = new Menu();
    TelNoteRegex regex = new TelNoteRegex();
    Operate operate = new Operate();
    File file = new File("/Users/JAVA/a.txt");
    ObjectInputStream ois = null;
    Object o = null;
    try {
        file.createNewFile();
        ois = new ObjectInputStream(new FileInputStream(file));
        if ((o = ois.readObject())==null){
            return;
        }else {
            operate.ObjectInputStreamDemo();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    while (true) {
        menu.mainMenu();
        int item = regex.menuItemValidate(1, 6);
        switch (item) {
            case 1:
                operate.addLogic();
                break;
            case 2:
                operate.searchLogic();
                break;
            case 3:
                operate.modifyLogic();
                break;
            case 4:
                operate.deleteLogic();
                break;
            case 5:
                operate.orderLogic();
                break;
            case 6:
                operate.ObjectOutputStreamDemo();
                System.exit(0);

        }
    }
}

我在这里做了判断了,为什么还会报EOF?

public void ObjectOutputStreamDemo(){
    ObjectOutputStream oos = null;
    try {
        oos = new ObjectOutputStream(new FileOutputStream("/Users/JAVA/a.txt",true));
        for (Person temp:list){
            oos.writeObject(temp);
        }
        oos.flush();
    }catch (Exception e){
        e.printStackTrace();
    }finally {
        try {
            if (oos!=null){
                oos.close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
public void ObjectInputStreamDemo(){
    ObjectInputStream ois = null;
    try {
        ois = new ObjectInputStream(new FileInputStream("/Users/JAVA/a.txt"));
        Person a = null;
        while(true){
            if ((a = (Person) ois.readObject())==null){
                break;
            }
            Person person =(Person) ois.readObject();
            this.list.add(person);
        }

    }catch (Exception e){
        e.printStackTrace();
    }finally {
        try {
            if(ois!=null){
                ois.close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

StreamCorruptedException这个报错我该怎么修改呢,有时候if语句中还会报类型强制转换的错误是为什么呢

JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 10827楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 10829楼
JAVA 全系列/第五阶段:网页编程和设计/HTML5(旧) 10830楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637