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;
} }
Java 过滤所有html标签,复制文件到指定位置的更多相关文章
- java 根据Url下载对应的文件到指定位置,读txt文件获取url
package test; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; im ...
- JAVA通过I/O流复制文件
JAVA通过I/O流复制文件 本文是对字节流操作,可以多音频视频文件进行操作,亲测有效. 个人感觉这个东西就是靠记的, 没什么好解释的,,,, import java.io.File; import ...
- java 提取目录下所有子目录的文件到指定位置
package folder; import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundExcept ...
- winform复制文件到指定目录
执行步骤 弹出选择对话框:var openFileDialog = new OpenFileDialog(); 设置选择内容,如所有图片:openFileDialog.Filter="图像文 ...
- scp复制文件到指定端口
1.scp基本格式 scp file user@host:/dir 2.scp复制文件到指定端口 scp默认连接的端口是22端口,如果ssh不是使用标准的22端口则使用-P(P大写)指定: scp - ...
- Dream------Java--ant zip 对压缩文件进行指定位置的修改
ant zip 对压缩文件进行指定位置的修改 实现功能: 对2中文件进行修改: 需求: 在XX文件中,从二进制流的200字节位置开始,往后的30位字节数量.插入一个值 由于涉及到公司内部,不方便写太多 ...
- shell如何在指定文件的指定位置后面添加内容
最近工作中遇到一个问题,想在某个文件的指定位置后面添加一个标志位,要求在shell脚本里实现. 问题说明: 想在sys_config.fex文本的某个字符串后面添加一个flag 例如:sys_conf ...
- Java之字符流操作-复制文件
package test_demo.fileoper; import java.io.*; /* * 字符输入输出流操作,复制文件 * 使用缓冲流扩展,逐行复制 * */ public class F ...
- linux复制文件到指定的文件夹
copy命令 该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,同MSDOS下的copy命令一样,功能十分强大. 语法: cp [选项] 源文件或目录 目标文件或目录 说明:该命令把指 ...
随机推荐
- UVA 10079 Pizze Cutting
题意:N条直线最多把平面分成几个部分 ans=1+(N+1)*N/2; 直线数量 1 2 3 4 …………n把平面分成的块数 2 4 7 11 1+1 1+1+2 1+1+2+3 1+1+2+3+4 ...
- python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'如何解决【转载】
原文转自:http://bbs.chinaunix.net/thread-4154743-1-1.html python3中用HTMLTestRunner.py报ImportError: No mod ...
- Appium+python自动化20-查看iOS上app元素属性【转载】
前言 学UI自动化首先就是定位页面元素,玩过android版的appium小伙伴应该都知道,appium的windows版自带的Inspector可以定位app上的元素Mac版的appium1.6的版 ...
- printf()函数不能直接输出string类型
因为string不是c语言的内置数据,所以直接printf输出string类型的是办不到的. 要这样输出: printf("%s\n",a.c_str()); 举例: #inclu ...
- POJ 2566:Bound Found(Two pointers)
[题目链接] http://poj.org/problem?id=2566 [题目大意] 给出一个序列,求一个子段和,使得其绝对值最接近给出值, 输出这个区间的左右端点和区间和. [题解] 因为原序列 ...
- iOS 设置系统音量和监听系统音量变化
很简单的调用 首先在工程引入MediaPlayer.framework #import <MediaPlayer/MediaPlayer.h> 1. 获取系统音量 // 获取系统音量 MP ...
- Java杂谈1——虚拟机内存管理与对象访问
1.理解JAVA虚拟机的内存管理 运行时的数据区 从java虚拟机的内存分配来看,一个java程序运行时包含了如下几个数据区: a) 程序计数寄存器(Program Counter Regis ...
- RS-232
RS-232 锁定 同义词 rs232一般指RS-232 本词条由“科普中国”百科科学词条编写与应用工作项目 审核 . 个人计算机上的通讯接口之一,由电子工业协会(Electronic Industr ...
- 为docker创建ubuntu带SSH的基础镜像
安装Debootstrap ubuntu操作系统:apt install debootstrap centos操作系统:yum install debootstrap 构建基础Ubuntu的rootf ...
- apache的动态和静态
apache的动态和静态 http://www.cnblogs.com/eoiioe/archive/2008/12/23/1360476.html(2.0和2.2一样) 关于apache的动态与静 ...