| | |
| | | public static String readContent(File file, String lineEnding) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | InputStreamReader is = null;
|
| | | BufferedReader reader = null;
|
| | | try {
|
| | | is = new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
|
| | | BufferedReader reader = new BufferedReader(is);
|
| | | reader = new BufferedReader(is);
|
| | | String line = null;
|
| | | while ((line = reader.readLine()) != null) {
|
| | | sb.append(line);
|
| | |
| | | System.err.println("Failed to read content of " + file.getAbsolutePath());
|
| | | t.printStackTrace();
|
| | | } finally {
|
| | | if (reader != null){
|
| | | try {
|
| | | reader.close();
|
| | | } catch (IOException ioe) {
|
| | | System.err.println("Failed to close file " + file.getAbsolutePath());
|
| | | ioe.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (is != null) {
|
| | | try {
|
| | | is.close();
|
| | |
| | | Path exactBase = Paths.get(getExactFile(basePath).toURI());
|
| | | Path exactPath = Paths.get(getExactFile(path).toURI());
|
| | | if (exactPath.startsWith(exactBase)) {
|
| | | return exactBase.relativize(exactPath).toString();
|
| | | return exactBase.relativize(exactPath).toString().replace('\\', '/');
|
| | | }
|
| | | // no relative relationship
|
| | | return null;
|