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文件的更多相关文章

  1. java读取数据写入txt文件并将读取txt文件写入另外一个表

    package com.xsw.test; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.F ...

  2. Java——读取和写入txt文件

    package com.java.test.a; import java.io.BufferedReader; import java.io.BufferedWriter; import java.i ...

  3. Asp.net读取和写入txt文件方法(实例)!

    Asp.NET读取和写入txt文件方法(实例)! [程序第一行的引入命名空间文件 - 参考] System; using System.Collections; using System.Config ...

  4. java读取字符串,生成txt文件

    /** * 读取字符串,生成txt 文件 已解决未设置编码时,在项目中直接打开文件,中文乱码问题 * WriteText.writeToText(musicInfo,fileName)直接调用 * * ...

  5. java读取UTF-8的txt文件发现开头的一个字符问题

    今天遇到一个奇葩问题,在读取一个TXT文件时,出现开头多了一个问号(?).如下图: 莫名奇妙的多了一个.最后通过网上资料,知道在Java中,class文件采用utf8的编码方式,JVM运行时采用utf ...

  6. C# 读取和写入txt文件

    读取: 1.使用StreamReader读取文件,然后一行一行的输出 StreamReader sr = new StreamReader(path,Encoding.Default); String ...

  7. java如何追加写入txt文件

    java中,对文件进行追加内容操作的三种方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.io.BufferedWriter; import  ...

  8. JAVA读取和写入properties文件

    1.读取 Properties prop = new Properties(); try { //这个getResourceAsStream方法就是把文件转为inputStream的方式 prop.l ...

  9. java 读取并且显示 txt 文件

    系统:mac os x 10.9 eclipse 在eclipse 中建立一个project, 命名为Cin_txt, Cin_txt的内容 test wang hello world 以下是输入的代 ...

随机推荐

  1. iOS 设置UILable字体,及计算长度和位置

    UILabel *lastLable = [[UILabel alloc] init]; UIFont *font = [UIFont fontWithName:lastLable.font.font ...

  2. Sublime Text3 常用快捷键动画演示及优秀插件分享

    Sublime Text 是前端的一个神器,以其精简和可DIY而让广大fans疯狂.好吧不吹了直入正题 -_-!! 首先是安装,如果你有什么软件管家的话搜一下就好,一键安装.然后,有钱的土豪就自己买个 ...

  3. iOS 之 Strong与Weak,_unsafe _unretained与weak区别

    1. 在ARC中 strong(强引用) 相当于retain, weak(弱引用) 相当于assign.ARC下,strong告诉编译器自动插入retain.但是在ARC下,代理协议的属性依然用ass ...

  4. BNU Online Judge-34973-Liserious战队

    题目链接 http://www.bnuoj.com/bnuoj/problem_show.php?pid=34973 题目不难,很容易,不过不仔细看题可能你一直做不出,注意<<一共分为1~ ...

  5. UltraISO制作linux启动盘(包含写入不完整解决方法)

    网上教程挺多,主要是自己记录一下.

  6. JS插件库

    http://www.cnblogs.com/xiaoyao2011/category/327551.html

  7. 将SWF文件用作资源打包

    使用Flash开发网页游戏少不了与各种美术资源打交道.对于静态资源的那就是各种图片,对于会动的资源可以考虑直接做成swf.制作成swf的美术资源又可以分为两种:一种是直接将关键帧罗列在主时间轴上,那么 ...

  8. 使用AngularJS的三个重要原因

    入门教程:http://www.ituring.com.cn/minibook/303 : http://angularjs.cn/tag/AngularJS 原因一:Google开发的框架 要知道开 ...

  9. html标签大全(2)

    http标签详解 声明 1:这里的文字都是我从我自己csdn账号拷贝过来,是本人学习总结的结晶,所以请尊重本作品.2:如要要转载本文章,则要说明文字的出处.3:如有哪里不对欢迎指出. 在上一篇文章中主 ...

  10. 《HelloGitHub月刊》第10期

    前言 这一年感谢大家的支持,小弟这里给大家拜年了! <HelloGitHub月刊>会一直做下去,欢迎大家加入进来提供更多的好的项目. 最后,祝愿大家:鸡年大吉- <HelloGitH ...