search

Home  >  Q&A  >  body text

java - 关于文件的问题

为什么会报错,求解决

大家讲道理大家讲道理2892 days ago360

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:59:25

    String dirPath = parentFile.getAbsolutePath();

    The code here will never be executed, so the editor reminds you that this is dead code

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 17:59:25

    The File type returned by getAbsoluteFile() is not String, so it should

    File f=new File("s").getParentFile().getAbsoluteFile();

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 17:59:25

    There is something wrong with your logic. If it is equal to null, but you want to get its absolute path, even if no error is reported, it must be NullPointException.

    reply
    0
  • 阿神

    阿神2017-04-17 17:59:25

    Think more about it yourself when encountering this kind of problem. This is obviously a grammatical error. You can see the cause of the error by placing your cursor on the red wavy line.

    reply
    0
  • Cancelreply