代码:

public class MainApplication {

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

              try{
                  // Open the file that is the first
                  // command line parameter
                  FileInputStream fstream = new FileInputStream("data/temp.CSV");
                  BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
                  String strLine;
                  //Read File Line By Line
                  while ((strLine = br.readLine()) != null)   {
                  // Print the content on the console
                  System.out.println (strLine);
                  }
                  //Close the input stream
                  in.close();
                    }catch (Exception e){//Catch exception if any
                  System.err.println("Error: " + e.getMessage());
                  }
      }
}

CSV文件数据:
19/1/13 13:58:04    0   1610    0   419 0   0
19/1/13 13:58:05    0.01    1599    66  432 0   1
19/1/13 13:58:06    0.02    1603    47  423 0   2
19/1/13 13:58:07    0.03    1602    26  413 0   3
19/1/13 13:58:08    0.04    1605    130 412 0   4

输出:

最佳答案


BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-16LE"));

代替
BufferedReader br = new BufferedReader(new InputStreamReader(in));

关于Java打印正方形(未知字符)以及常规tex,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14588435/

10-10 03:20