2021-04-01

ObjectInputStream loop EOFException handling

 





Method#1


FileInputStream fis = new FileInputStream("input-file.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
 
while(fis.available() > 0) {
  Object obj = ois.readObject()
  ...
}





Method#2




...

         //write instance of EofIndicatorClass at EOF
         oout.writeObject(new EofIndicatorClass());


...

          /*
         *If oin.readObject() returns instanceof EofIndicatorClass that means
         *it's EOF, exit while loop and EOFException will not be thrown.
         */
         Object obj;
         while(!((obj =  oin.readObject()) instanceof EofIndicatorClass)){
             System.out.println(obj);
         }


...














2021-03-30

Spring Boot 1.5.19.RELEASE, mvn package FAILURE

 

Eclipse
Spring Boot 1.5.19.RELEASE








https://docs.spring.io/spring-boot/docs/1.5.19.RELEASE/reference/htmlsingle/#getting-started-first-application-executable-jar



[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.027 s
[INFO] Finished at: 2021-03-30T12:44:16+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.19.RELEASE:repackage (default) on project test-spring-boot-xxxxxxxxx: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.19.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.tiongnam.xxxxxxxxx.test_spring_boot_xxxxxxxxx.App, test.tiongnam.xxxxxxxxx.controller.Example] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException



By Adding @SpringBootApplication to Example.java