Code example for PrintStream

Methods: checkError, println, write

0
String str = e.toString();
    // Send the whole thing as UTF8. 
    try { 
      byte [] utf8 = str.getBytes("UTF8");
      out.write(utf8, 0, utf8.length);
    } catch (java.io.UnsupportedEncodingException ex) {
      System.out.println("Oops... can't encode to UTF8... Exiting");
      System.exit(0);
    } 
    out.println();
    // Flush the output and check for errors. 
    boolean error = out.checkError();
    if (error) {
      System.out.println("Connection error. Quitting ScrollView Server...");
      System.exit(0);
    } 
  } 
 
  /** Read one message from client (assuming there are any). */ 
  public static String receiveMessage() throws IOException {