Can a File Object Alone Read a File?

  • Thread starter Thread starter Punkyc7
  • Start date Start date
  • Tags Tags
    File
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Punkyc7
Messages
415
Reaction score
0
Can a File object alone be used to read a file?

I am thinking it is no because don't you have to use the scanner class to get the data from the file?

I have tried looking for this online but haven't been able to find the answer.
 
Physics news on Phys.org
I should probably add this is in java
 
Punkyc7 said:
Can a File object alone be used to read a file?

I am thinking it is no because don't you have to use the scanner class to get the data from the file?

I have tried looking for this online but haven't been able to find the answer.

Punkyc7 said:
I should probably add this is in java
Yes, that would be good to do.

The File class has no methods for reading (or writing to) a File instance. For the methods on the File class, see http://docs.oracle.com/javase/1.5.0/docs/api/java/io/File.html.