public void run() { try { BufferedReader bf = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf8")); while (true) { print(bf.readLine()); } } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) throws IOException { Card card = new Card(Card.DIAMOND, Card.ACE); reflect(card); // Create object using reflection // Class name is specified in a document(test.txt) FileInputStream fis = new FileInputStream("test.txt"); InputStreamReader reader = new InputStreamReader(fis, "utf8"); BufferedReader br = new BufferedReader(reader); String filename = br.readLine(); Object obj = create(filename); print("Object created: " + obj); // Get field value Object p1 = new Pipe(20, "Rubber"); print("length by getFieldValue: " + getFieldValue("length", p1)); print("type by getFieldValue: " + getFieldValue("type", p1)); // Call method // If parameters required, type: new Class[0], // value: new Object[0] call("repair", p1, new Class[0], new Object[0]); call("repair", p1, new Class[] {int.class, String.class}, new Object[] {11, "Metal"}); }