Reading files with Intellij idea IDE

后端 未结 7 762
野的像风
野的像风 2020-12-14 00:51

I am a long time eclipse user and I have started to play around with IntelliJ IDEA.

So from my understanding, a project in IntelliJ is the same as the Eclipse worksp

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 01:39

    u need to specify complete path inside quotes something like this-->
    
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
    
    public class Application {
        public static void main(String[] args) throws FileNotFoundException {
            File file = new File("E:\\coding\\ProcessingFiles\\src\\myfile.txt");
            Scanner input = new Scanner(file);
            while (input.hasNextLine()){
                String line = input.nextLine();
                System.out.println(line);
            }
            input.close();
    
        }
    }
    

提交回复
热议问题