X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=src%2Fde%2Fj32%2Futil%2FUtil.java;h=cd4efb8a5e20fcf32383806e3fcb6f7da630e6a0;hb=aa75934c56fbe55732fd790eaa1c3b3676d80f41;hp=95a3f7873a740adef6a55b2557c3fd569bdac47d;hpb=4095790c7943e91462bce2072234fe53f610f95b;p=jpim.git diff --git a/src/de/j32/util/Util.java b/src/de/j32/util/Util.java index 95a3f78..cd4efb8 100644 --- a/src/de/j32/util/Util.java +++ b/src/de/j32/util/Util.java @@ -6,35 +6,45 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Iterator; -public class Util { - - public static E nonnull(E ob) { - if (ob == null) - throw new NullPointerException(); - return ob; - } - - public static void transfer(InputStream is, OutputStream os) - throws IOException { - byte[] buffer = new byte[16384]; - int len = -1; - while ((len = is.read(buffer)) != -1) - os.write(buffer, 0, len); - } - - public static void nothrowClose(Closeable c) { - if (c != null) { - try { - c.close(); - } catch (IOException e) {} - } - } - - public static E first(Iterable i) - { - Iterator it = i.iterator(); - if (it.hasNext()) - return it.next(); - return null; - } +public class Util +{ + + public static E nonnull(E ob) + { + if (ob == null) throw new NullPointerException(); + return ob; + } + + public static void transfer(InputStream is, OutputStream os) + throws IOException + { + byte[] buffer = new byte[16384]; + int len = -1; + while ((len = is.read(buffer)) != -1) + os.write(buffer, 0, len); + } + + public static void nothrowClose(Closeable c) + { + if (c != null) { + try { + c.close(); + } + catch (IOException e) {} + } + } + + public static E first(Iterable i) + { + Iterator it = i.iterator(); + if (it.hasNext()) return it.next(); + return null; + } + + public static E first(Iterator it) + { + if (it.hasNext()) return it.next(); + return null; + } + }