0

Is it possible to load in a txt file into java, but from a folder in say the c: drive - as opposed to placing the text file in the java project itself?

Thanks in advance for any help

5
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by JamesCherrill
0

Just include the FULL path in the File object:

File f = new File("C:/Program Files/Java/file.txt");

So what really happens when I entered that line of code??
Does that code automatically do something when performed by the system?,
or another line of code will have follow it for something to happen??

0

what really happens when I entered that line of code

Please show the "line of code" you are referring to.

for something to happen

What is the "something" that is to happen?
Each executable statement does something or causes something to happen.

0

It just creates a File object that refers to the file with that path & name, but it doesn't actually do anything with it (not even check if the file exists!). You can then call methods on that File object to test if it exists, open it and read it etc

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.