java读取和写入txt文件
package com.yinghuo.testDES;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import com.sun.corba.se.pept.encoding.OutputObject;
public class test1 {
public static void main(String[] args){
String inPath = "C:\\Users\\lb\\Desktop\\testDES\\encrypt.txt";
String outPath = "C:\\Users\\lb\\Desktop\\testDES\\write.txt";
readWriteFile(inPath, outPath);
}
public static void readWriteFile(String inPath, String outPath){
File inFile = new File(inPath);
File outFile = new File(outPath);
try {
InputStreamReader read = new InputStreamReader(new FileInputStream(inFile));
BufferedReader bufferR = new BufferedReader(read);
OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(outFile));
BufferedWriter out = new BufferedWriter(write);
String inLine;
if(inFile.isFile() && inFile.exists()){
while((inLine = bufferR.readLine()) != null){
out.write(inLine+"\r\n");
out.flush();
}
read.close();
write.close();
System.out.println("");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java读取和写入txt文件的更多相关文章
- java读取数据写入txt文件并将读取txt文件写入另外一个表
package com.xsw.test; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.F ...
- Java——读取和写入txt文件
package com.java.test.a; import java.io.BufferedReader; import java.io.BufferedWriter; import java.i ...
- Asp.net读取和写入txt文件方法(实例)!
Asp.NET读取和写入txt文件方法(实例)! [程序第一行的引入命名空间文件 - 参考] System; using System.Collections; using System.Config ...
- java读取字符串,生成txt文件
/** * 读取字符串,生成txt 文件 已解决未设置编码时,在项目中直接打开文件,中文乱码问题 * WriteText.writeToText(musicInfo,fileName)直接调用 * * ...
- java读取UTF-8的txt文件发现开头的一个字符问题
今天遇到一个奇葩问题,在读取一个TXT文件时,出现开头多了一个问号(?).如下图: 莫名奇妙的多了一个.最后通过网上资料,知道在Java中,class文件采用utf8的编码方式,JVM运行时采用utf ...
- C# 读取和写入txt文件
读取: 1.使用StreamReader读取文件,然后一行一行的输出 StreamReader sr = new StreamReader(path,Encoding.Default); String ...
- java如何追加写入txt文件
java中,对文件进行追加内容操作的三种方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.io.BufferedWriter; import ...
- JAVA读取和写入properties文件
1.读取 Properties prop = new Properties(); try { //这个getResourceAsStream方法就是把文件转为inputStream的方式 prop.l ...
- java 读取并且显示 txt 文件
系统:mac os x 10.9 eclipse 在eclipse 中建立一个project, 命名为Cin_txt, Cin_txt的内容 test wang hello world 以下是输入的代 ...
随机推荐
- C# 定时器计划任务
函数类: public class MyPlan { public void RunMyplan(object source, ElapsedEventArgs e) { //读取配置文件设定的日期时 ...
- doubango(5)--SIP协议栈传输层的启动
SIP协议的INVITE消息发起流程 当通过sip协议发起一个会话时,需要通过invite消息实现该流程.而SIP协议是一个基于事务的协议,每一个sip会话的都是通过sip部件间的一系列消息来完成的. ...
- 怎么应用vertical-align,才能生效?
vertical-align 的使用 以前总是想要一些元素垂直居中对齐,经常用line-height,可是对于图片来说,line-height的表现并不理想(非常不理想)可看我的文章:line-he ...
- zstuoj 4243
牛吃草 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 441 Solved: 139 Description 农夫有一个长满草的(x0, y0)为圆心 ...
- 字符串匹配KMP算法中Next[]数组和Nextval[]数组求法
数据结构课本上给了这么一段算法求nextval9[]数组 int get_nextval(SString T,int &nextval[ ]) { //求模式串T的next函数修正值并存入数组 ...
- ES1:Windows下安装ElasticSearch
ElasticSearch(简称ES)是一个基于Lucene的分布式全文搜索服务器,本随笔演示在Windows安装ElasticSearch和用于管理ES的Head插件. ElasticSearch官 ...
- ADO.NET 防止SQL注入
规避SQL注入 如果不规避,在黑窗口里面输入内容时利用拼接语句可以对数据进行攻击 如:输入Code值 p001' union select * from Info where '1'='1 //这样可 ...
- 通过实例解释LinuxC下argc,argc[]的意义
MarkdownPad Document html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,ab ...
- 从你的全世界切过(胡说八道支持向量机SVM小故事)
背景 据说很久很久以前, 澳门有一家"胡说八道大赌场", 专门提供各种奇奇怪怪的玩法. 其中有一个赌博叫"从你的全世界切过"(连名字也这么奇怪). 玩法是在一张 ...
- C#编程基础->XML系列导航
缘由 最近开发的小程序过程中需要涉及到XML相关操作,突然发现自己对于这知识点了解的太少,急需学习加强.刚好项目的时间也不是很紧急,自己就总结XML相关知识点.一个方面自己学习,一个方面也希望可以帮到 ...