[UNSOLVED] Access Another File In A Different Package In JAR

Discussion in 'Plugin Development' started by r0306, Jun 29, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    r0306

    Hello. I'm having trouble access a file named for example: Data.txt stored in a package named com.pluginname.storage from a class in a different package named com.pluginname.util. I have called this class ClassA.class for short. Below is the code I have tried using but it always throws a InvalidArgumentException saying that the file was not found. It only works when the text file is in the same package as the class file. Below is what I am using to get the text file:

    Code:
    InputStream stream = ClassA.class.getResourceAsStream("/com/pluginname/storage/Data.txt");
     
  2. Offline

    petteyg359

    You want ClassLoader.
     
  3. Offline

    r0306

  4. Offline

    petteyg359

Thread Status:
Not open for further replies.

Share This Page