The system cannot find the file specified in java

前端 未结 8 897
轮回少年
轮回少年 2020-11-28 08:52

I am making a program that opens and reads a file. This is my code:

import java.io.*;

public class FileRead{
    public static void main(String[] args){
           


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 09:15

    You need to give the absolute pathname to where the file exists.

            File file = new File("C:\\Users\\User\\Documents\\Workspace\\FileRead\\hello.txt");
    

提交回复
热议问题