1 package org.sapia.clazzy; 2 3 import java.io.ByteArrayOutputStream ; 4 import java.io.IOException ; 5 import java.io.InputStream ; 6 7 24 public class Utils { 25 26 static final int BUFSZ = 1096; 27 28 35 public static byte[] streamToBytes(InputStream is) throws IOException { 36 int read = 0; 37 byte[] buf = new byte[BUFSZ]; 38 ByteArrayOutputStream bos = new ByteArrayOutputStream (BUFSZ); 39 while((read = is.read(buf)) > 0) { 40 bos.write(buf, 0, read); 41 } 42 return bos.toByteArray(); 43 } 44 45 50 public static String getPackageNameFor(String className){ 51 int i = className.lastIndexOf('.'); 52 if(i < 0){ 53 return null; 54 } 55 else{ 56 return className.substring(0, i); 57 } 58 } 59 60 } 61 | Popular Tags |