mercredi 29 avril 2015

open a file in netbeans

I use this method in opening files, but when i opened my project it won't run because its from a mac device. where do i store the txt file and what should i write instead of

(new File("D:\\description.txt"));

the method

 Scanner inStream = null;
    try {
  inStream = new Scanner(new File("D:\\description.txt"));
}
catch (FileNotFoundException e) {
System.out.println("Erorr openenig the file");
}

while (inStream.hasNextLine ()) {
    String line = inStream.nextLine();
    System.out.println(line);
}

Aucun commentaire:

Enregistrer un commentaire