1: …… 2: public void f() { 3: Properties props = new Properties(); 4: .... 5: if ( in !=null && in.available() > 0 ) { 6: props.load(in); 7: if ( props == null || props.isEmpty() ) 8: return ; 9: } 10: String type = props.getProperty("type"); 11: Worker w; 12: 13: // 외부 입력되는 값에 대해 유효성을 검증하여야한다. 14: if (type == null || "".equals(type)) return; 15: if (type.equals("Slow" )) { 16: w = new SlowWorker(); 17: w.doAction(); 18: } else if (type.equals("Hard" )) { 19: w = new HardWorker(); 20: w.doAction(); 21: } else { 22: System.err.printf("No propper class name!"); 23: } 24: …… 25: } 26: 27: abstract class Worker { 28: String work = ""; 29: public abstract void doAction(); 30: }