java调用linux命令GBK转码UTF-8

package com;

import java.io.*;
public class Ceshi{
public static void main(String[] args) {
                // TODO Auto-generated method stub
                  try{
                    Process process=Runtime.getRuntime().exec("iconv -f GBK -t utf-8 src.txt -o desc.txt" );
                    InputStreamReader ir=new InputStreamReader(process.getInputStream());
                    LineNumberReader input=new LineNumberReader(ir);
                    String line;
                    while((line=input.readLine())!=null){
                    System.out.println(line);
                    }
                }catch(IOException ioe){
                    System.err.println("IOException:"+ioe.getMessage());
                }
        }
}

你可能感兴趣的:(java,linux,F#)