Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package inner.ru;
  2.  
  3. import java.io.File;
  4.  
  5. public class Check {
  6. private final File file = new File("src//inner//file//hello.txt");
  7.  
  8. public void print() {
  9. System.out.println(file.exists());
  10. }
  11. }
  12.  
  13. package external.main;
  14.  
  15. import inner.ru.Check;
  16.  
  17. public class Main {
  18.  
  19. /**
  20. * @param args the command line arguments
  21. */
  22. public static void main(String[] args) {
  23. Check check = new Check();
  24. check.print();
  25. }
  26.  
  27. }
  28.  
  29. private final File file = new File("src//inner//file//hello.txt");
  30.  
  31. public void print() {
  32. try (final InputStream stream = Check.class.getResourceAsStream("/inner/file/hello.txt")) {
  33. java.util.Scanner s = new java.util.Scanner(stream);
  34. while (s.hasNext()) {
  35. System.out.println(s.nextLine());
  36. }
  37. } catch (IOException ex) {
  38. System.out.println("File doesn't exist");
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement