In java, when we create a file, we create files using the name of the extension. For example :
File file = new File("D:/light.txt");
I would like to know what type of file format do we get when we create a file without the file extension type. For example :
File file = new File("D:/light");
This answer assumes you're doing more than just creating a File
object - that you're actually creating a file on the file system. (A File
object is just a logically representation of a file system entry which may or may not exist.) If you're really just creating a File
object, read EJP's answer - at that point, you've basically just got a name. That doesn't have a "type" or a "format".
The extension is just part of the name. The operating system may try to use that to display a different icon, or launch a specific application when you double-click on the icon, or whatever - but it's really just part of the name.
Fundamentally, a file consists of:
Unless you deliberately add metadata, it's typically just inherited (default permissions etc).
You can write any data in any file - just because a file has an extension of .txt
doesn't mean it's definitely a text file. It could have content which is actually MP3-encoded audio data, for example. Whether the OS uses the file extension or the content to work out what to do with the file is up to the OS.
What type of File is created when we create new File without the extension?
No file is created at all, and there is only one type of File
.
In java, when we create a file, we create files using the name of the extension.
Or not.
For example:
File file = new File("D:/light.txt");
I would like to know what type of file format do we get when we create a file without the file extension type.
You don't. You don't get any file format at all, because you don't get a file: only a File
object in memory.
For example:
File file = new File("D:/light");
You can produce all the examples you want, but no file is created, and no file format.
In any case Java doesn't care about filename extensions. Your operating system might, but that's a different story.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With