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. fold change(ratio)

    fold change 英文简称 : FC 中文全称 : 倍性变化 所属分类 : 生物科学 词条简介 : 一种用于描述两个用于相比的对象数量差异的方法.例如,第一个样本和第二个样本的量是50/10,那 ...

  2. xdebug.var_display_max_data

    Xdebug Display Full Details on var_dump() Xdebug is an excellent addition to a PHP developers arsena ...

  3. 利用JS做到隐藏div和显示div

    div的visibility可以控制div的显示和隐藏,但是隐藏后页面显示空白 style="visibility: none;" document.getElementById( ...

  4. METRO风格

    METRO风格是指微软在WINDOWS PHONE 7中新加入的界面风格,并且计划将其用于windows8中的开始菜单界面.该界面的特点是简洁高效,每一个METRO图标都没有边框,形状有点像地铁站中的 ...

  5. Delphi TRect函数例子

    {   在网上看到个这个例子感觉还不错,将它移到自己的博客里没事的时候看看:   TRect    作用:保存一个矩形的左上角和右下角的坐标值:      声明:       type TRect = ...

  6. Windows server 2008 R2 64位系统安装ZendOptimizer-3.3.0a-Wind

    如果不安装ZEND的话,一些PHP网站程序使用ZEND加密后就无法使用,比如DISCUZ,SHOPEX,ECSHOP等,所以要想安装这些程序,ZEND是一定要安装的,要不会出现乱码等问题. 安装ZEN ...

  7. 用fluent模拟内循环床气化燃烧(调试过程记录)

    模拟对象为文献Combined gasification of coal and biomass in internal circulating fluidized bed[1]中的内循环气化炉.[1]h ...

  8. php如何判断是手机访问还是电脑访问

    <?php function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AG ...

  9. adb server无法启动方法,结束占用端口的进程

    adb server is out of date.  killing...ADB server didn't ACK* failed to start daemon *error: unknown ...

  10. jQuery replaceWith replaceAll end的用法

    jQuery replaceWith replaceAll end的用法 <%@ page language="java" import="java.util.*& ...