LogPreProcess
2016-04-06 14:09
288 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text;
namespace LogPreProcess
{
class Program
{
public static bool isOpen = true;
public static void Write(string path,string content)
{
FileStream fs = new FileStream(path, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(content);
sw.Flush();
sw.Close();
fs.Close();
}
public static void Read(string path)
{
StreamReader sr = new StreamReader(path, Encoding.Default);
String line;
StringBuilder strBuilder = new StringBuilder();
while ((line = sr.ReadLine()) != null)
{
//Console.WriteLine(line.ToString());
if (line.Contains("[S"))
{
isOpen = false;
continue;
}
else if (line.Contains("[R"))
{
isOpen = true;
}
if (isOpen)
{
strBuilder.Append(line);
strBuilder.Append("\r\n");
}
}
string content = strBuilder.ToString();
Write(path+".txt", content);
}
static void Main(string[] args)
{
Read(args[0]);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text;
namespace LogPreProcess
{
class Program
{
public static bool isOpen = true;
public static void Write(string path,string content)
{
FileStream fs = new FileStream(path, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(content);
sw.Flush();
sw.Close();
fs.Close();
}
public static void Read(string path)
{
StreamReader sr = new StreamReader(path, Encoding.Default);
String line;
StringBuilder strBuilder = new StringBuilder();
while ((line = sr.ReadLine()) != null)
{
//Console.WriteLine(line.ToString());
if (line.Contains("[S"))
{
isOpen = false;
continue;
}
else if (line.Contains("[R"))
{
isOpen = true;
}
if (isOpen)
{
strBuilder.Append(line);
strBuilder.Append("\r\n");
}
}
string content = strBuilder.ToString();
Write(path+".txt", content);
}
static void Main(string[] args)
{
Read(args[0]);
}
}
}
相关文章推荐
- Android Signed APK
- HDOJ 2055 An easy problem
- 解决Clock skew detected.
- C++递归实现strlen函数功能
- lightingpool 解决SDE无法连接的问题
- svnadmin dump and load
- C# 上传文件并生成缩略图
- 递推之错排公式
- 网页中如何使用一些特殊字体
- 同花顺C++笔试
- codeforces_598D. Igor In the Museum(dfs)
- Json转换时报错/Json解析方法
- Spring AOP 详解
- poj 2229&wustoj 1269划分数(简单dp)
- ubuntu 安装netdata
- QT中配置opencv可能的问题
- 史上最全WebView使用,附送Html5Activity一份
- iOS七种传值总结(关键代码)
- 解决mac osx下pip安装ipython权限的问题
- ArrayList转换类型为DataTable类型