系统运维

占位

删除过期账号实例

1、导出一个注册用户表的用户名数据

2、导出最近一年登陆的用户名数据

比较两个文件的差异

grep -wvFf file1.txt file1.txt

//存在于file2文件中,但不存在于file1文件的行

替换每行的后缀

sed -ie 's/@xxx$/@xxx.com/' xxx.txt

查找文件某行数据

sed -n '3457,1p' xxx.txt

InputStream、byte[] 互转

InputStream转byte[]

private byte[] getBytesFromInputStream(InputStream is) throws IOException {
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
int ch;
while ((ch = is.read()) != -1) {
bytestream.write(ch);
}
byte imgdata[] = bytestream.toByteArray();
bytestream.close();
return imgdata;
}

byte[]转InputStream

byte[] data;
InputStream is = new ByteArrayInputStream(data);

http://mingkg21.javaeye.com/blog/431067