Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help With Read Text From File


MorpheusZero
 Share

Recommended Posts

So I'm coding something that builds a list, from reading a txt file. The code itself works and has been tested outside of the realm of the Minecraft developing environment, but I can't get it to work correctly with Forge. I get a crash with file not found. So I was wondering if anyone knew what path I should be adding to find the file? As in, should I use a file path using only MY MODS directories, or should I make it look all through the minecraft folders example: ./minecraft/mods/-mymod or can I simply have it it search locally with my file path only like: /com/morpheuszero/mods/name.txt etc etc?

 

I've tried a few different ways and II can't get it to work because I don't know which directory Forge is running from to know where to put a file path to read my file....I'm doing it this way because the information in this file needs to be easily changed by other users to be able to add the output of this file to an array list so I don't have to recode it and make the array larger it just builds itself each launch as pertaining to each user of the mod.

Link to comment
Share on other sites

I don't know if you figured this out, but here is what I have found that seems to work.

 

 

 

File myFile = FMLCommonHandler.instance().getMinecraftServerInstance().getFile("hello_world.txt");

System.out.println("Location: " + myFile.getAbsolutePath());

 

 

 

Output:

 

2013-11-22 17:48:37 [iNFO] [sTDOUT] Location: C:\Users\cody\forge_hardcore_mod\mcp\jars\.\hello_world.txt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.