标签:
public static String filterHtml(String string) { String str = string.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "").replaceAll("</[a-zA-Z]+[1-9]?>", ""); return str; }
复制文件到指定位置 public static boolean inPutStreamTofile(InputStream inStream, String targetfile) { FileOutputStream fs = null; try { File target = new File(targetfile); File dir = target.getParentFile(); if (!dir.exists()) { dir.mkdirs(); } if (target.exists()) { target.delete(); } target.createNewFile(); fs = new FileOutputStream(target); byte[] buffer = new byte[1024]; int byteread = 0; while ((byteread = inStream.read(buffer)) != -1) { fs.write(buffer, 0, byteread); } return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { if (fs != null) { try { fs.close(); } catch (IOException e) { e.printStackTrace(); } } if (inStream != null) { try { inStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }
public static boolean copyfile(File source, String targetfile) { try { InputStream inStream = new FileInputStream(source); return inPutStreamTofile(inStream, targetfile); } catch (FileNotFoundException e) { e.printStackTrace(); return false; } }
标签:
原文地址:http://www.cnblogs.com/sallet/p/4250399.html