Here you can find the source of getResourcePath()
Reads the relative path to the resource directory from the <code>testResourcePath</code> file located in <code>src/test/resources</code> http://stackoverflow.com/questions/21567497/how-to-output-text-to-a-file-in-resource-folder-maven
resources
in the file system, or null
if there was an error
public static String getResourcePath()
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.URI; public class Main { /**/*from w ww .jav a 2 s. c o m*/ * Reads the relative path to the resource directory from the <code>testResourcePath</code> file located in * <code>src/test/resources</code> * http://stackoverflow.com/questions/21567497/how-to-output-text-to-a-file-in-resource-folder-maven * @return the relative path to the <code>resources</code> in the file system, or * <code>null</code> if there was an error */ public static String getResourcePath() { try { String resourcePathFile = System.class.getResource("/testResourcePath").getFile(); String resourcePath = new BufferedReader(new FileReader(resourcePathFile)).readLine(); URI rootURI = new File("").toURI(); URI resourceURI = new File(resourcePath).toURI(); URI relativeResourceURI = rootURI.relativize(resourceURI); return relativeResourceURI.getPath(); } catch (Exception e) { return null; } } }