I have made a plugin for this mine craft server and its a diary, you write stuff down on a .txt and you can read it in game. I set it up so you can change the directory in game and the creating files and reading them works fine on windows until I found out the sever owner is on a mac, is it possible to create file and read them the same as windows to mac?
Asked
Active
Viewed 613 times
-2
-
Yes. Here you have an example of reading and writing : http://stackoverflow.com/a/22074145/3315914 – rpax Mar 12 '14 at 20:43
-
1Did you try it and see? – Mike B Mar 12 '14 at 20:44
-
If you wrote a good code the answer is yes. – vzamanillo Mar 12 '14 at 20:45
1 Answers
1
Java is a highly portable language. Your code will work as long as you don't place any Windows-specific assumptions in your code. For example, this is bad:
new File("C:\\My\\Directory\\File.txt");
This is better...
new File("/My/Directory/File.txt");
Better still...
new File(File.separator + "My" + File.separator + "Directory" + File.separator + "File.txt");
Best!
File file = new File(File.separator);
file = new File(file, "My");
file = new File(file, "Documents");
file = new File(file, "File.txt");
Read the JavaDocs for more info on how to accomplish your goals in a system-independent way.

64BitBob
- 3,110
- 1
- 17
- 23