#502 Replaced usages of System.out with logger.
This commit is contained in:
		| @@ -22,6 +22,9 @@ | ||||
|  */ | ||||
| package com.iluwatar.tolerantreader; | ||||
|  | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.io.IOException; | ||||
|  | ||||
| /** | ||||
| @@ -41,31 +44,33 @@ import java.io.IOException; | ||||
|  */ | ||||
| public class App { | ||||
|  | ||||
|   private static final Logger LOGGER = LoggerFactory.getLogger(App.class); | ||||
|  | ||||
|   /** | ||||
|    * Program entry point | ||||
|    */ | ||||
|   public static void main(String[] args) throws IOException, ClassNotFoundException { | ||||
|     // Write V1 | ||||
|     RainbowFish fishV1 = new RainbowFish("Zed", 10, 11, 12); | ||||
|     System.out.println(String.format("fishV1 name=%s age=%d length=%d weight=%d", fishV1.getName(), | ||||
|         fishV1.getAge(), fishV1.getLengthMeters(), fishV1.getWeightTons())); | ||||
|     LOGGER.info("fishV1 name={} age={} length={} weight={}", fishV1.getName(), | ||||
|         fishV1.getAge(), fishV1.getLengthMeters(), fishV1.getWeightTons()); | ||||
|     RainbowFishSerializer.writeV1(fishV1, "fish1.out"); | ||||
|     // Read V1 | ||||
|     RainbowFish deserializedFishV1 = RainbowFishSerializer.readV1("fish1.out"); | ||||
|     System.out.println(String.format("deserializedFishV1 name=%s age=%d length=%d weight=%d", | ||||
|     LOGGER.info("deserializedFishV1 name={} age={} length={} weight={}", | ||||
|         deserializedFishV1.getName(), deserializedFishV1.getAge(), | ||||
|         deserializedFishV1.getLengthMeters(), deserializedFishV1.getWeightTons())); | ||||
|         deserializedFishV1.getLengthMeters(), deserializedFishV1.getWeightTons()); | ||||
|     // Write V2 | ||||
|     RainbowFishV2 fishV2 = new RainbowFishV2("Scar", 5, 12, 15, true, true, true); | ||||
|     System.out.println(String.format( | ||||
|         "fishV2 name=%s age=%d length=%d weight=%d sleeping=%b hungry=%b angry=%b", | ||||
|     LOGGER.info( | ||||
|         "fishV2 name={} age={} length={} weight={} sleeping={} hungry={} angry={}", | ||||
|         fishV2.getName(), fishV2.getAge(), fishV2.getLengthMeters(), fishV2.getWeightTons(), | ||||
|         fishV2.getHungry(), fishV2.getAngry(), fishV2.getSleeping())); | ||||
|         fishV2.getHungry(), fishV2.getAngry(), fishV2.getSleeping()); | ||||
|     RainbowFishSerializer.writeV2(fishV2, "fish2.out"); | ||||
|     // Read V2 with V1 method | ||||
|     RainbowFish deserializedFishV2 = RainbowFishSerializer.readV1("fish2.out"); | ||||
|     System.out.println(String.format("deserializedFishV2 name=%s age=%d length=%d weight=%d", | ||||
|     LOGGER.info("deserializedFishV2 name={} age={} length={} weight={}", | ||||
|         deserializedFishV2.getName(), deserializedFishV2.getAge(), | ||||
|         deserializedFishV2.getLengthMeters(), deserializedFishV2.getWeightTons())); | ||||
|         deserializedFishV2.getLengthMeters(), deserializedFishV2.getWeightTons()); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user