0

I was given a piece of code that has this line:

GetBytes getInput = new GetBytes("myText.txt");

Which obviously reads a text file and tries to get its input.

I am using jdk1.8.0_20 on Windows 8 running inside eclipse.

In which folder should I put a file named myText.txt?

tony9099
  • 4,567
  • 9
  • 44
  • 73
  • Your question is somewhat unspecific. You mentioned in a comment of an answer that you are running the program through Eclipse. In this case, this is an important information since eclipse does stuff in the background. Please include this information in your question. – Turing85 Apr 17 '15 at 19:03

2 Answers2

1

First:

GetBytes getInput = new GetBytes("myText.txt");

You forgot the last parenthesis there.

Second:

It goes in the same folder as your class is in.

Nicholas Eason
  • 290
  • 4
  • 13
  • I am using eclipse and putting them where the classes are combined does not work – tony9099 Apr 17 '15 at 18:54
  • 1
    Try right-clicking the project and hitting refresh. Eclipse might not know that it's there yet – Nicholas Eason Apr 17 '15 at 18:56
  • 2
    @NicholasEason this will not work. Eclipse runs the program from the project's root directory and sets the classpath via command line options. Therefore, OP needs to put `myText.txt` in the root directory of the project. – Turing85 Apr 17 '15 at 18:58
  • @Turing85 indeed. putting the file at the root folder did the trick. Thanks a lot. If you want, you can post this comment as an answer and I will accept it.I think it is better for the community – tony9099 Apr 17 '15 at 19:01
0

GetBytes is a class that was given to you, I presume? The code in that class should specify which folder it looks in. Usually, the default is the same folder as the class. Since GetBytes is a custom class, it could be anywhere, though. If you can't figure it out, post the code for the GetBytes class.

Alejandro
  • 1,168
  • 8
  • 11