使用JAVA POI api从Excel读取普通话

使用JAVA POI api从Excel读取普通话,java,unicode,apache-poi,Java,Unicode,Apache Poi,我需要从excel文件中读取普通话数据,以便将其保存在数据库中。但Unicode字符正在崩溃。 我正在做下面的事情 FileInputStream myInput = new FileInputStream(fileName); POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput); Workbook workbook = new HSSFWorkbook(myFileSystem); Sheet sheet = workboo

我需要从excel文件中读取普通话数据,以便将其保存在数据库中。但Unicode字符正在崩溃。 我正在做下面的事情

 FileInputStream myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
Workbook workbook = new HSSFWorkbook(myFileSystem);
Sheet sheet = workbook.getSheetAt(0);

for (Row row : sheet) {
    for (Cell cell : row) {
    String str = null;
    switch (cell.getCellType()) {
    case Cell.CELL_TYPE_STRING:
        cell= CellUtil.translateUnicodeValues(cell);
        str = cell.getRichStringCellValue().getString();
        System.out.println(str);
        break;
    case Cell.CELL_TYPE_NUMERIC:
        str = new Long((long) cell.getNumericCellValue())
            .toString();
        System.out.println(str);
        break;
    default:
        System.out.println("It's here");
    }
    }
}

请您详细说明一下Unicode字符的变化情况好吗?您确定System.out.println对Unicode字符正常工作吗?通常JVM输出不是为unicode设置的,这会让您误以为POI是坏的,而不是坏的。谢谢大家,上面的程序运行良好。我错过了这些东西,因为我的电脑上没有安装语言支持。这就是为什么控制台输出中出现Unicode字符的原因。