zoukankan      html  css  js  c++  java
  • Java 过滤所有html标签,复制文件到指定位置

    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;
            }
            
        }
  • 相关阅读:
    Docker之Linux UnionFS
    Docker之Linux Cgroups
    Docker之Linux Namespace
    理解Docker容器的进程管理
    Docker命令详解
    协同过滤和基于内容推荐有什么区别?
    Docker 有什么优势?
    kubernetes
    Docker如何为企业产生价值?
    关于网页的几种高度说明
  • 原文地址:https://www.cnblogs.com/sallet/p/4250399.html
Copyright © 2011-2022 走看看