Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Xocky, Feb 2, 2020.
How can you create your own file type and read/write it in java?
File types are born in the vast lands of Atlantis when the Moon and the sun are perfectly aligned to shine onto the altar of the mighty windows; then you have to sacrifice a penguin to the mighty macintosh, and in the light of the shrine you will find that a new file type is born!
Jokes aside, you'd read/write your file just as you would do with any other file
A file extension is just an identifier. It doesn't do anything by itself. So just save the file as whatever.yourawesomeextension and it will be the same as saving it as whatever.txt
Yes. You can open a JAR file as an image if it is in png format. File extension doesn't do anything except being more understandable for the user.
Fun fact: Linux doesn't have a concept of file extensions
Fun fact: Not everyone uses linux
I know - I was just trying to hint to OP that file extensions don't really mean anything, especially on Linux
Depends on the extension & program.
For example i can create a .dat file, doesn't mean minecraft could use it unless that file PROPERLY followed the NBT format.
TLDR; The extension, file content and program used matters a lot.
Haha, i actually have popcorn somewhere, but dinner is being made
Of course - however if I rename the .dat file to just "hello", and then edit minecraft to reflect the new path changes, then it'll still read it fine.
And of course it must follow the NBT format - I never said otherwise. I said that the file extension doesn't change anything to do with how the file is read and how data is written to it, hence why Linux doesn't use them
this is way off topic, can we stop?
for writing to/from a file, it depends on the file format you want it to have. yml, json, whatever dat is technically called, standard txt, ect. you use specific methods of saving to and from a file. it depends on the format you want. if you want a simple txt read/writer, the Files java api has this for you already, or you can manually do it yourself with FileReader and FileWriter objects. a quick google of this would tell you more in depth explanations.
Other fun fact: some apps use file extensions like .conf etc...
It's not off-topic. We're explaining to the OP what is really file extensions
True. A file is just a collection of bytes. You can use a text format like json, yaml, etc... or use a "raw" format like NBT (Usually named foo.dat) which write directly bytes, int etc... in an OutputStream using a byte (NBTTagEnd's type id) to separe values