View Javadoc

    1   package sharin.util;
    2
    3   import java.io.IOException;
    4   import java.io.InputStream;
    5   import java.io.Reader;
    6   import java.io.Writer;
    7
    8   public class IoUtils {
    9
    10      public static int read(Reader reader) {
    11
    12          try {
    13              return reader.read();
    14
    15          } catch (IOException e) {
    16              throw new RuntimeException(e);
    17          }
    18      }
    19
    20      public static void write(Writer writer, String str) {
    21
    22          try {
    23              writer.write(str);
    24
    25          } catch (IOException e) {
    26              throw new RuntimeException(e);
    27          }
    28      }
    29
    30      public static void close(InputStream in) {
    31
    32          try {
    33              in.close();
    34
    35          } catch (IOException e) {
    36              throw new RuntimeException(e);
    37          }
    38      }
    39  }