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 以下是输入的代 ...
随机推荐
- OSG和osgearth显示中文(转载)
osgEarth支持中文过程详解 OSG和osgearth显示中文 一.知识储备 要想很好的理解和解决这个问题,首先要了解什么是多字节和宽字节.说实话我之前也知道这两个字节到底有什么区别,只是简单 ...
- WEB 开发者应该具备的 6 大技能?
1. 界面和用户体验 注意,浏览器的实现标准是不一致的,请确保你的网站能够兼容所有主流的浏览器.最少需要测试的有 Gecko 引擎 (Firefox),WebKit引擎(Safari以及一些手机浏览器 ...
- 安装 mrtg
http://blog.csdn.net/cnbird2008/article/details/2072627
- 在DFS和BFS中一般情况可以不用vis[][]数组标记
开始学dfs 与bfs 时一直喜欢用vis[][]来标记有没有访问过, 现在我觉得没有必要用vis[][]标记了 看代码 用'#'表示墙,'.'表示道路 if(所有情况都满足){ map[i][j]= ...
- swift webView的高度自适应内容
废话不多 直接上代码 //在webView的协议方法里实现以下代码 func webViewDidFinishLoad(webView: UIWebView) {//加载完成 // se ...
- 我用Cocos2d-x模拟《Love Live!学院偶像祭》的Live场景(四)
[前言和思路整理] 千呼万唤Shǐ出来!最近莫名被基友忽悠着进舰坑了,加上要肝LL活动,又碰上公司项目紧张经常加班,这一章发得比以往时候来得更晚一些,抱歉啊. 上一章我们实现了BeatObjectMa ...
- 深入理解HTTP协议(转)
http协议学习系列 1. 基础概念篇 1.1 介绍 HTTP是Hyper Text Transfer Protocol(超文本传输协议)的缩写.它的发展是万维网协会(World Wide Web C ...
- Wireshark对常见视频应用的抓包分析的结果
一.PC端直播: YY客户端直播用的udp(P2P)9158客户端直播用的rtp/rtcp 二.Web端直播: YY网页端直播用的tcp9158网页端直播用的tcp六间房网页端直播用的tcp17173 ...
- JS日期时间加减实现
首先,上代码 var diffDate = function(date, diff) { return new Date( Date.UTC( date.getUTCFullYear(), date. ...
- VS Code C# 插件离线版 1.6.2
VS Code C# 插件离线版,目前最新稳定版为:1.6.2 . 由于在扩展中下载C#插件总是缓慢,或者容易出现错误,特制作离线版本共享出来. 本离线版本为Windows版本,其他系统请在扩展中下载 ...