package hiveTest;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer; public class GBKTransferUTF8 { private static void transferFile(String srcFileName, String destFileName) throws IOException {
String line_separator = System.getProperty("line.separator");
FileInputStream fis = new FileInputStream(srcFileName);
StringBuffer content = new StringBuffer();
DataInputStream in = new DataInputStream(fis);
BufferedReader d = new BufferedReader(new InputStreamReader(in, "GBK"));// , "UTF-8"
String line = null;
while ((line = d.readLine()) != null)
content.append(line + line_separator);
d.close();
in.close();
fis.close(); Writer ow = new OutputStreamWriter(new FileOutputStream(destFileName), "utf-8");
ow.write(content.toString());
ow.close();
} public static void main(String[] args) throws IOException { String srcFileName="C:\\Users\\lenovo\\Desktop\\大数据设计\\community_data\\data_example_to_qiaokai.txt";
String destFileName="C:\\Users\\lenovo\\Desktop\\大数据设计\\community_data\\data_example_to_qiaokai-utf8.txt";
GBKTransferUTF8.transferFile(srcFileName, destFileName);
}
}

java将文件转为UTF8工具类的更多相关文章

  1. Java操作文件夹的工具类

    Java操作文件夹的工具类 import java.io.File; public class DeleteDirectory { /** * 删除单个文件 * @param fileName 要删除 ...

  2. java中文件操作的工具类

    代码: package com.lky.pojo; import java.io.BufferedReader; import java.io.BufferedWriter; import java. ...

  3. Java一个文件上传工具类

    /** * 文件上传 * * @author cary * @since 2012-12-19 下午2:22:12 */ public class FileUploader { static fina ...

  4. spring boot 文件上传工具类(bug 已修改)

    以前的文件上传都是之前前辈写的,现在自己来写一个,大家可以看看,有什么问题可以在评论中提出来. 写的这个文件上传是在spring boot 2.0中测试的,测试了,可以正常上传,下面贴代码 第一步:引 ...

  5. Java中创建操作文件和文件夹的工具类

    Java中创建操作文件和文件夹的工具类 FileUtils.java import java.io.BufferedInputStream; import java.io.BufferedOutput ...

  6. 文件上传工具类 UploadUtil.java

    package com.util; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import ja ...

  7. spring mvc 文件上传工具类

    虽然文件上传在框架中,已经不是什么困难的事情了,但自己还是开发了一个文件上传工具类,是基于springmvc文件上传的. 工具类只需要传入需要的两个参数,就可以上传到任何想要上传的路径: 参数1:Ht ...

  8. Java汉字转成汉语拼音工具类

    Java汉字转成汉语拼音工具类,需要用到pinyin4j.jar包. import net.sourceforge.pinyin4j.PinyinHelper; import net.sourcefo ...

  9. //读取配置文件(属性文件)的工具类-ConfigManager

    package com.pb.news.util; import java.io.IOException;import java.io.InputStream;import java.sql.Resu ...

随机推荐

  1. Java学习个人备忘录之线程间的通信

    线程间通讯多个线程在处理同一资源,但是任务却不同. class Resource { String name; String sex; } //输入 class Input implements Ru ...

  2. 20172330 2017-2018-1 《Java程序设计》第五周学习总结

    20172330 2017-2018-1 <Java程序设计>第五周学习总结 教材学习内容总结 第五章 首先是对各种各种运算符的了解:刚开始以为相等就是=,还有其他一些符号都挺简单的,然后 ...

  3. Java Class Object

    Object类 它是所有类的基类. public class Person { } //实际上是 public class Person extends Object { } Object类的方法 t ...

  4. SQL 单表分页存储过程和单表多字段排序和任意字段分页存储过程

      第一种:单表多字段排序分页存储过程       --支持单表多字段查询,多字段排序 create PROCEDURE [dbo].[UP_GetByPageFiledOrder] ( ), --表 ...

  5. YaoLingJump开发者日志(九)V1.1.1版本完成

    跳跃吧瑶玲下载连接 百度网盘下载 介绍   Android版本升级到8.0,发现原来的图标不显示了:   百度了一下解决方案,用了该博客提供的第二种方法,修改roundIcon的内容.   可爱的图标 ...

  6. 【week2】Scrum中的站立会议

    Scrum站立会议    站立会议给我的第一印象就是站着开会,在经过我查阅资料之后,发现也是差不多的意思.学术一点的分析就是在Sprint开始后,团队将会在每个工作日特定时间举行一个简短会议,每次会议 ...

  7. HBase 所有命令解析

    COMMAND GROUPS:Group name: generalCommands: status, table_help, version, whoami Group name: ddlComma ...

  8. docker配置网络

    1.暂停服务,删除旧网桥#service docker stop#ip link set dev docker0 down#brctl delbr docker0 2.创建新网桥bridge0#brc ...

  9. git & configs

    git & configs https://alvinalexander.com/git/git-show-change-username-email-address https://stac ...

  10. 使用户浏览器添加没有的字体@font-face

    @font-face的用法 @font-face { font-family: 'MyWebFont'; src: url('webfont.eot'); /* IE9 Compat Modes */ ...