zoukankan      html  css  js  c++  java
  • 路径正确下,Eclipse读取txt文件仍失败

    症状:使用Eclipse读取文件时,路径输入确认正确(前提!!!),但控制台总报错:

    错误类型一:

    Exception in thread "main" java.io.FileNotFoundException: file.txt (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.util.Scanner.<init>(Unknown Source)
        at helloworld.main(helloworld.java:9)

    错误类型二:“文件名,目标名,或卷积语法不正确”

    错误类型三:读取的文件为空

    原因:text file encoding修改过,导致无法读取txt文件

    解决方法:在Window-Preferences-General-Workspace中,将Workspace页面左下角的Text file encoding改为默认的Default(GBK),其他编码方式不确定是否可以。(博主之前修改成UTF-8格式后,就读不了文件了/(ㄒoㄒ)/~~)

  • 相关阅读:
    第十二章类的无参方法
    第十三章人机猜拳
    第十一章类和对象
    面向对象七大原则。
    深入类的方法。
    使用集合组织相关数据。
    .NET框架
    C#数据类型
    错误。
    实现Windows的数据绑定
  • 原文地址:https://www.cnblogs.com/ticktack/p/6596622.html
Copyright © 2011-2022 走看看