-1

I am able to read a file using java,File is in eclipse workspace. My file location is:src\test\resources So,I have given like this. String filePath = "\src\test\resources\ARImport_Copy3.csv";

This is working fine but when i am running in jenkins ,I am getting not able to load file messages.

Please provide me the solution.

sivakrishna
  • 45
  • 2
  • 5
  • 1
    This isn't a place for someone to just provide you the solution. Please post what you have tried and we will try to help you fix the problem in your code. – Arachnid Hivemind Feb 24 '16 at 18:07

1 Answers1

0

Reading file directly from filesystem is not flexible. You can't control what working directory would be when executed by different tools in different environments.

It is more reliable to read a resource file from classpath like this:

URL url = this.getClass().getResource("/ARImport_Copy3.csv");
File testFile = new File(url.getFile());

A broader discussion you will find here: Easy way to get a test file into JUnit

Community
  • 1
  • 1
nolexa
  • 2,392
  • 2
  • 19
  • 19