package pyUML.backend; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * some helper methods for common java problems, i.e. file copying */ public class JavaHelperMethods { /** * Fast & simple file copy. * copies source file to destination file */ public static void copy(File source, File dest) throws IOException { InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(dest); final int bufferSize = 4096; try { byte[] buffer = new byte[bufferSize]; int bytesRead; while ((bytesRead = in.read(buffer)) >= 0) { out.write(buffer, 0, bytesRead); } } finally { out.close(); in.close(); } } public static InputStream stringToStream(String s) { return new ByteArrayInputStream(s.getBytes()); } /** * Joins an Array of Strings to one big String separated by * a separator * @param array The String array to join * @param separator The separator * @return the joined String */ public static String join(String[] array, String separator) { if (array==null) return ""; StringBuffer sb = new StringBuffer(array[0]); for(int i=1; i