Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package inner.ru;
- import java.io.File;
- public class Check {
- private final File file = new File("src//inner//file//hello.txt");
- public void print() {
- System.out.println(file.exists());
- }
- }
- package external.main;
- import inner.ru.Check;
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Check check = new Check();
- check.print();
- }
- }
- private final File file = new File("src//inner//file//hello.txt");
- public void print() {
- try (final InputStream stream = Check.class.getResourceAsStream("/inner/file/hello.txt")) {
- java.util.Scanner s = new java.util.Scanner(stream);
- while (s.hasNext()) {
- System.out.println(s.nextLine());
- }
- } catch (IOException ex) {
- System.out.println("File doesn't exist");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement