public static string filterhtml (String string) {string str = String.replaceall ("<[a-za-z]+[1-9]?[ ^><]*> "," "). ReplaceAll (" </[a-zA-Z]+[1-9]?> "," "); return str;}
Copy the file to the specified location 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 { new fileinputstream (source); return inputstreamtofile (instream, targetfile); } Catch (FileNotFoundException e) { e.printstacktrace (); return false ; } }
Java Filter All HTML tags, copy files to the specified location