Search code examples
javafileweblogic

How do I access a file with Weblogic?


I need to access a file for some data in weblogic. I have this in my code,

File file = new File("myfile.csv");

When I run the code I get "File Not Found" error.

Where is the code actually looking for the file? I placed the code in a few different locations, but I cant get it to work.


Solution

  • If the file is at the root of your application's classpath, you can use getClass().getResource("myfile.csv");. If it's within a subdirectory, provide that path information in addition to the filename.