Java 读取csv文件
2017-01-20 16:24
483 查看
public static void read(String path) { File file = new File(path); if (!file.exists() || file.isDirectory()) { System.out.println(path); System.out.println("文件不存在或是path为文件夹"); return; } BufferedReader br = null; try { /** * csv文件每个单元格使用,分割 * 默认ANSI编码 */ br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "gbk")); String msg = ""; msg = br.readLine(); while (msg!=null) { System.out.println(msg); msg = br.readLine(); } } catch (FileNotFoundException e) { System.out.println("创建流文件异常:文件没找到"); e.printStackTrace(); } catch (IOException e) { System.out.println("流文件读取异常:" + e.toString()); e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { System.out.println("流文件关闭出现异常:" + e.toString()); e.printStackTrace(); } } } }
相关文章推荐
- IE条件注释,嗅探低版本IE用户,并引导升级
- Spring 面向切面(AOP)编程,注解
- springmvc + freemarker 开发环境 缓存设置
- java中路径问题详解
- Java与C#时间戳同步
- 详解springmvc拦截器拦截静态资源
- 【Java每日一题】20170120
- java中堆内存和栈内存的区别
- 【Java每日一题】20170120
- 初识JAVA
- java web个人通讯录系统设计
- 动态代理(java原生动态代理)
- 分布式锁(1):Java 常用技术方案
- Eclipse中显示line number
- Spring 使用注解方式进行事务管理
- Spring Boot启动过程(三)
- 设计模式练习(14)——迭代器模式
- RxJava 中view相关的实用类
- 使用IntelliJ IDEA 15和Maven创建Java Web项目
- SpringMVC 拦截器不拦截静态资源的三种处理方式方法