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;
} }

Java 过滤所有html标签,复制文件到指定位置的更多相关文章

  1. java 根据Url下载对应的文件到指定位置,读txt文件获取url

    package test; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; im ...

  2. JAVA通过I/O流复制文件

    JAVA通过I/O流复制文件 本文是对字节流操作,可以多音频视频文件进行操作,亲测有效. 个人感觉这个东西就是靠记的, 没什么好解释的,,,, import java.io.File; import ...

  3. java 提取目录下所有子目录的文件到指定位置

    package folder; import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundExcept ...

  4. winform复制文件到指定目录

    执行步骤 弹出选择对话框:var openFileDialog = new OpenFileDialog(); 设置选择内容,如所有图片:openFileDialog.Filter="图像文 ...

  5. scp复制文件到指定端口

    1.scp基本格式 scp file user@host:/dir 2.scp复制文件到指定端口 scp默认连接的端口是22端口,如果ssh不是使用标准的22端口则使用-P(P大写)指定: scp - ...

  6. Dream------Java--ant zip 对压缩文件进行指定位置的修改

    ant zip 对压缩文件进行指定位置的修改 实现功能: 对2中文件进行修改: 需求: 在XX文件中,从二进制流的200字节位置开始,往后的30位字节数量.插入一个值 由于涉及到公司内部,不方便写太多 ...

  7. shell如何在指定文件的指定位置后面添加内容

    最近工作中遇到一个问题,想在某个文件的指定位置后面添加一个标志位,要求在shell脚本里实现. 问题说明: 想在sys_config.fex文本的某个字符串后面添加一个flag 例如:sys_conf ...

  8. Java之字符流操作-复制文件

    package test_demo.fileoper; import java.io.*; /* * 字符输入输出流操作,复制文件 * 使用缓冲流扩展,逐行复制 * */ public class F ...

  9. linux复制文件到指定的文件夹

    copy命令      该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,同MSDOS下的copy命令一样,功能十分强大. 语法: cp [选项] 源文件或目录 目标文件或目录 说明:该命令把指 ...

随机推荐

  1. fmap为什么可以用function作为第二个参数

    看看fmap的类型 fmap :: Functor f => (a -> b) -> f a -> f b 很明显的,第一个参数是function,第二个参数是functor的 ...

  2. linux下挂载U盘【转】

    转自:http://www.cnblogs.com/yeahgis/archive/2012/04/05/2432779.html 一.Linux挂载U盘:1.插入u盘到计算机,如果目前只插入了一个u ...

  3. C 语言中char* 和const char*的区别

    const char *p = "123"; p[1] = '3'; // 会报错p = "456"; // 不会报错 const char * 只是说指针指向 ...

  4. mysql中数据类型的长度

    这是一篇很全面的博客的网址 http://qimo601.iteye.com/blog/1622368 下图是其中一部分截图,在mysql数据库中新建数据表时有个长度的设置

  5. 我使用的Sublime插件及配置

    我使用的Sublime插件及配置 增强型插件 Package Control 快捷键ctrl+~,调出命令行,运行: import urllib.request,os,hashlib; h = '29 ...

  6. WPF+MVVM数据绑定问题集锦

    1.  数据绑定的问题 在使用数据绑定时,一般使用 ObservableCollection<T> 类,不使用list列表集合,因为list数据发生变化时,UI界面不更新,而Observa ...

  7. hdu 畅通工程系列题目

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1232 并查集水. #include <stdio.h> #include <iost ...

  8. printf()函数不能直接输出string类型

    因为string不是c语言的内置数据,所以直接printf输出string类型的是办不到的. 要这样输出: printf("%s\n",a.c_str()); 举例: #inclu ...

  9. (15)oracle序列

    1.创建序列 CREATE SEQUENCE EMP_SEQ START WITH 1 MAXVALUE 9999999999999999999999999999 MINVALUE 1 NOCYCLE ...

  10. Paint Fence -- LeetCode

    There is a fence with n posts, each post can be painted with one of the k colors. You have to paint ...