linux中文乱码

txt文件在linux环境下打开呈现了乱码状态。

解决方法1:在linux用iconv命令,如乱码文件名为zhongwen.txt,那么在终端输入如下命令:

iconv -f gbk -t utf8 zhongwen.txt > zhongwen.txt.utf8

如果eclipse打开后仍是乱码,则需进入preferrence,修改默认编码格式为utf-8

解决方法2:如果需要批量的将gbk文件转成utf8文件,则需要编写如下java程序:

package classifier;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.mahout.classifier.bayes.BayesParameters;


public class ClassifierDriver {

public static void main(String[] args) throws Exception {

// set bayes parameter
BayesParameters params = new BayesParameters();
params.setBasePath(args[2]);
params.set("classifierType", args[3]);
params.set("alpha_i", "1.0");
params.set("defaultCat", "unknown");
params.setGramSize(1);

// set configuration
Configuration conf = new Configuration();
conf.set("bayes.parameters", params.toString());

// create job
Job job = new Job(conf,"Classifier");
job.setJarByClass(ClassifierDriver.class);

// specify input format
job.setInputFormatClass(KeyValueTextInputFormat.class);

// specify mapper & reducer
job.setMapperClass(classifier.ClassifierMapper.class);
job.setReducerClass(ClassifierReducer.class);

// specify output types of mapper and reducer
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(Text.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);

// specify input and output DIRECTORIES
Path inPath = new Path(args[0]);
Path outPath = new Path(args[1]);
FileInputFormat.addInputPath(job, inPath);
FileOutputFormat.setOutputPath(job,outPath); // output path

// delete output directory
try{
FileSystem hdfs = outPath.getFileSystem(conf);
if(hdfs.exists(outPath))
hdfs.delete(outPath);
hdfs.close();
} catch (Exception e){
e.printStackTrace();
return ;
}

// run the job
System.exit(job.waitForCompletion(true) ? 0 : 1);

}

}

转载于:https://www.cnblogs.com/mlj5288/p/4439159.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/419999.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

c语言用for编程图形,C语言编程题求解

2009-05-13C语言简单的编程题求解1.从键盘输入一//将四个函数编成四个子函数了,在一个主函数里调用,你若需要,分别取出来用也可以。以下源代码,VS2005编译通过。//1。从键盘输入一行字符,分别统计其中字母字符和数字字…

2.3线性表的链式存储和运算—单链表应用举例

例2.5 已知单链表H,写一算法将其倒置。即实现如图2.22的操作。(a)为倒置前,(b)为倒置后。 算法思路:依次取原链表中的每个结点,将其作为第一个结点插入到新链表中去,指针p用来指向当前结点,p为空时结束。 算…

c语言see函数,vprintf() - C语言库函数

C库函数 int vprintf(const char *format, va_list arg) 发送格式化输出到stdout使用一个参数列表传递给它。声明以下是 vprintf() 函数的声明。intvprintf(constchar*format,va_list arg)参数format -- 这是包含文本的字符串被写入到缓冲。它可以包含嵌入的格式在随后的附加…

js获取checkbox值的方法

js获取checkbox值的方法。分享给大家供大家参考。具体实现方法如下&#xff1a;<html> <head> <meta http-equiv"Content-Type" content"text/html; charsetutf-8"> <title>js</title> </head> <script language&q…

c语言占用cpu的程序,Windows下用C语言获取进程cpu使用率,内存使用,IO情况

转自&#xff1a; http://zhangyafeikimi.iteye.com/blog/378658process_stat.h/** file * brief 进程统计信息函数的声明 * author 张亚霏 * date 2009/05/03 * version 0.1 * */ #ifndef PROCESS_STAT_H #define PROCESS_STAT_H #ifdef __cplusplus extern "C" { #…

oracle 本地使用命令导入数据到远程主机

第一步:装载oracle客户端 第二部:配置tnsnames.ora.  db_172.21.1.7 (DESCRIPTION (ADDRESS (PROTOCOL TCP)(HOST 172.21.1.7)(PORT 1526))(CONNECT_DATA (SERVER DEDICATED)(SERVICE_NAME db))) 第三部:打开命令行,执行如下命令: imp netelnusr/netelnusrdb_172.21.1.7…

c语言计算据标准时间多少天,C语言系列--时间处理

首先明确几个概念UTC 协调世界时&#xff0c;又称世界标准时间或世界协调时间。GMT 格林尼治平均时间或格林尼治标准時間&#xff0c;由于地球每天的自转是有些不规则的&#xff0c;而且正在缓慢减速&#xff0c;因此格林威治时间已经不再被作为标准时间使用日历时间&#xff0…

Perl学习笔记(六)--文件(一)

一、文件描述符&#xff1a; 访问文件时用来代表文件的数字。 它是系统资源&#xff0c;系统限制打开的文件描述符数量。 Perl中只在某些系统调用时才使用它 文件句柄&#xff1a; 功能同文件描述符&#xff0c;但是与文件描述符不是一个东西。 Perl使用文件句柄代表文件。 文件…

android mkdirs 不起作用,Android mkdirs()创建一个零字节文件而不是文件夹

在我的Android应用程序中,我试图在SD卡上创建以下文件夹&#xff1a;/mnt/sdcard/OSGiComponents/admin/felix-cache/这是代码&#xff1a;File cacheDir new File( Environment.getExternalStorageDirectory().getAbsolutePath() "/OSGiComponents/admin/felix-cache/&qu…

向ComboBox列表框中添加Enum的全部数据

相当于利用反射的 GetValues与GetNames foreach (HETieXinType theType in Enum.GetValues(typeof(HETieXinType))) foreach (string mode in Enum.GetNames(typeof(BooleanInteractionMode))) { ledResponseModesComboBox.Items.Add(mode); switchResponseModesComboBox.Items…

android sqlite 备份数据库文件,android – 将SQLite数据库备份和还原到sdcard

这是我的代码&#xff1a;// Local databaseInputStream input new FileInputStream(from);// create directory for backupFile dir new File(DB_BACKUP_PATH);dir.mkdir();// Path to the external backupOutputStream output new FileOutputStream(to);// transfer bytes…

Spring中配置数据源的4种形式 ---转

不管采用何种持久化技术&#xff0c;都需要定义数据源。Spring中提供了4种不同形式的数据源配置方式&#xff1a; spring自带的数据源(DriverManagerDataSource)&#xff0c;DBCP数据源&#xff0c;C3P0数据源,JNDI数据源。 1.spring自带的数据源 DriverManagerDataSource XML…

android中拖动文字实现功能,Android:图片中叠加文字,支持拖动改变位置

之所以做了这么一个Demo&#xff0c;是因为最近项目中有一个奇葩的需求&#xff1a;用户拍摄照片后&#xff0c;分享到微信的同时添加备注&#xff0c;想获取用户在微信的弹出框输入的内容&#xff0c;保存在自己的服务器上。而事实上&#xff0c;这个内容程序是无法获取的&…

Mac 下nginx 环境的配置

这个是在度娘那里学来的。 因为是使用brew所以先安装&#xff1a; 安装命令如下&#xff1a;curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1当brew安装成功后&#xff0c;就可以随意安装自己想要的软件了&#xff0c;例如w…

android抽屉屏幕右滑,android - Android - 使滑动抽屉从左向右滑动 - 堆栈内存溢出...

我使用下面的XML布局在我的应用程序中实现了“Sliding Drawer”:(我从androidpeople.com得到了这个例子)android:layout_width"fill_parent" android:layout_height"fill_parent"xmlns:android"http://schemas.android.com/apk/res/android"andr…

bzoj 3196/tyvj p1730 二逼平衡树

原题链接&#xff1a;http://www.tyvj.cn/p/1730 树套树。。。 如下&#xff1a; 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<algorithm> 5 #define lc root<<1 6 #define rc root<<1|1 7 #define INF…

观察者模式与Boost.Signals

1&#xff09; 观察者模式定义 略&#xff0c;各种设计模式的书上都有定义。 2&#xff09; 观察者模式一般实现 观察者模式一般实现&#xff0c;都是“被观察者”保存一个“观察者”的列表&#xff0c;循环这个列表来通知“观察者”。代码&#xff0c;其中使用了boost的智能…

Android获取最新发送短信的基本信息,没有之一

注册&#xff1a; getContentResolver().registerContentObserver( Uri.parse("content://sms"), true, new SmsObserver(this, new Handler())); 监听&#xff1a; //用于检测发出的短信 public class SmsObserver extends Conten…

联想android刷机教程,超详细的联想刷机教程~带你嘻刷刷

一、刷机是什么说到“刷机”&#xff0c;很多人可能会和“升级”混淆起来&#xff0c;其实升级和刷机并不是同一概念。通俗地讲&#xff0c;升级就是对手机内的软件或系统进行升级&#xff0c;比如很多厂商手机都支持的OTA空中在线升级。而刷机&#xff0c;则相当于就是重装系统…