C#中一个简单的输入输出流
来源:互联网 发布:java的switch里的 编辑:程序博客网 时间:2024/05/20 13:41
从D:\1.txt中一行一行读取数据,再一行一行写入到D:\2.txt.
非常简单非常基础的一个例子,但由于经常用,故放在这里作为备忘。
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace userFliter{ class Program { static void Main(string[] args) { String[] org=File.ReadAllLines("d:/1.txt"); String newText=null; for (int i = 0; i < org.Length; i++) { newText = newText + org[i] + "\r\n"; } StreamWriter sw = new StreamWriter("d:/2.txt"); sw.Write(newText); sw.Flush(); sw.Close(); } }}
如果加上过滤条件,就是如下效果:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace userFliter{ class Program { static void Main(string[] args) { String[] org=File.ReadAllLines("d:/1.txt"); String newText=null; String temp = null; for (int i = 0; i < org.Length; i++) { temp = org[i]; temp = filter(temp); newText = newText + temp + "\r\n"; } StreamWriter sw = new StreamWriter("d:/2.txt"); sw.Write(newText); sw.Flush(); sw.Close(); } static private String filter(String oldLine) { //在这里对每行文字做处理 //********************** //********************** return oldLine; } }}
0 0
- C#中一个简单的输入输出流
- C中简单的输入输出流
- java中输入输出流的简单应用
- C#的输入输出流
- C#的输入输出流
- C#的输入输出流
- C#的输入输出流
- C#的输入输出流
- c#的输入输出流
- C#的输入输出流
- 一个简单的输入输出替换问题
- 一个简单的输入输出算法题
- Java中关于最简单的输入输出字节流操作
- IO流的简单输入输出
- c++重载io输入输出操作符的一个简单例子
- c#中一个简单的深拷贝方法
- 如何在C#中使用sqlite,一个简单的类
- C#关于输入输出流的知识点
- Tomcat server.xml优化
- 2016华为开发者大赛沙龙北京站,趁“热”来袭
- 通俗解释Android studio中gradle的作用
- 资料总结
- nyoj 6 喷水装置
- C#中一个简单的输入输出流
- 面试题36:数组中的逆序对
- 11.Identify the memory component from which memory may be allocated for:
- web页面开发过程中让图片垂直居中的三种方法
- Eclipse项目转Android Studio
- CnCrypt代码 之 为对话框动态增加菜单
- KMP 算法 ---经典
- 【转】MATERIALIZED VIEW
- Tomcat catalina.sh 优化