Reads file resource from path with variable replacement support.
@param filePath
@param context
@return
559769
public static Resource getFileResource(String filePath, TestContext context) {
        if (filePath.contains(FILE_PATH_CHARSET_PARAMETER)) {
            return new PathMatchingResourcePatternResolver().getResource(
                    context.replaceDynamicContentInString(filePath.substring(0, filePath.indexOf(FileUtils.FILE_PATH_CHARSET_PARAMETER))));
        } else {
            return new PathMatchingResourcePatternResolver().getResource(
                    context.replaceDynamicContentInString(filePath));
        }
    }
70590
public static List<String> readStringList(String filePath, Charset charset) throws IOException {
        FileInputStream stream = new FileInputStream(filePath);
        return readStringList(stream, charset);
    }
1103348
public static String getResourceAsString(final String resourcePath) {
        File resource = getFileForResource(resourcePath);

        if (!resource.exists() || resource.isDirectory()) {
            logger.error("Cannot read resource, does not exist"
                    + " (or is a directory).");
            return "";
        }

        try {
            return FileUtils.readFileToString(resource);
        } catch (IOException ioe) {
            logger.error(ioe.getMessage());
            return "";
        }
    }
1266963
public static String readFileContentToString(String filePath)
            throws IOException {
        String content = "";
        content = Files.toString(new File(filePath), Charsets.UTF_8);
        return content;
    }
615954
public byte[] getFileBytes(String filePath)
		throws IOException {
	    
		byte[] out = null;
		String path = (String) Utils.intern(filePath);
		RandomAccessFile raf = null;
		synchronized (path) {
			File file = null;
			try {
				file = new File(path);
				boolean exists = file.exists();
				if (exists) {
					byte[] fileBytes = new byte[(int)file.length()];
					raf = new RandomAccessFile(file,"r");
					raf.readFully(fileBytes);
					out = fileBytes;
				} else {
				    String msg = 
				        "File does not exist. (" + filePath + ")";
					mLog.error(msg);
					throw new IOException(msg);
				}
			} catch (IOException e) {
				mLog.error("Error writing: " + filePath);
				mLog.error(e);
				throw e;
			} finally {
				if (raf != null) {
					raf.close();
				}
			}
		}
		return out;
    }
882430
def read_file(filepath: str) -> str:
    """"""
    # ? Check this is ok if absolute paths passed in
    filepath = os.path.expanduser(filepath)
    with open(filepath) as opened_file:  # type: IO
        file_read = opened_file.read()  # type: str
        return file_read
366403
public static double[][] readFromFile(String filePath) {
		double[][] weights;
		
		Vector<double[]> listOfWeights = new Vector<>();
		
		try {
			// Open the file
			FileInputStream fis = new FileInputStream(filePath);
			InputStreamReader isr = new InputStreamReader(fis);
			BufferedReader br = new BufferedReader(isr);
			
			int numberOfObjectives = 0;
			int j;
			String aux = br.readLine();
			while (aux != null) {
				StringTokenizer st = new StringTokenizer(aux);
				j = 0;
				numberOfObjectives = st.countTokens();
				double[] weight = new double[numberOfObjectives];
				
				while (st.hasMoreTokens()) {
					weight[j] = new Double(st.nextToken());
					j++;
				}
				
				listOfWeights.add(weight);
				aux = br.readLine();
			}
			br.close();
			
			weights = new double[listOfWeights.size()][numberOfObjectives];
			for (int indexWeight = 0; indexWeight < listOfWeights.size(); indexWeight++) {
				System.arraycopy(listOfWeights.get(indexWeight), 0, weights[indexWeight], 0, numberOfObjectives);
			}
		} catch (Exception e) {
			throw new JMetalException("readFromFile: failed when reading for file: " + filePath + "", e);
		}
		
		return weights;
	}
695531
@Override
	public String load(final String filePath) {
		if (StringUtils.isEmpty(filePath)) {
			throw new IllegalArgumentException("Invalid file path. filePath=" + filePath);
		}
		String targetFilePath = getFilePath(trimSqlExtension(filePath.replace(".", PATH_SEPARATOR)));
		String sql = null;

		URL resource = Thread.currentThread().getContextClassLoader().getResource(targetFilePath);
		if (resource != null) {
			try (InputStream is = resource.openStream()) {

				sql = trimSlash(read(new BufferedReader(new InputStreamReader(is))));

				LOG.debug("Loaded SQL template.[{}]", targetFilePath);
			} catch (IOException e) {
				throw new UroborosqlRuntimeException("Failed to load SQL template[" + targetFilePath + "].", e);
			}
		}

		if (sql == null) {
			throw new UroborosqlRuntimeException("SQL template could not found.[" + targetFilePath + "]");
		}
		return sql;
	}
814509
public static String readResourceAsStream(String path) {
        try {
            InputStream inputStream = ResourceUtil.getResourceAsStream(path);
            return ResourceUtil.readFromInputStreamIntoString(inputStream);
        } catch (Exception e) {
            throw new DataUtilException("Failed to load resource", e);
        }
    }
469350
@Override
	protected Reader generateResource(String path, GeneratorContext context) {

		Reader reader = helper.createResource(context);

		String filePath = helper.getFilePath(path);
		if (filePath != null) {
			long lastModified = rsHandler.getLastModified(filePath);
			FilePathMapping fMapping = new FilePathMapping(filePath, lastModified);
			addLinkedResources(path, context, Arrays.asList(fMapping));
		}

		return reader;
	}
440250
public <X> DataSource<X> readFile(FileInputFormat<X> inputFormat, String filePath) {
		if (inputFormat == null) {
			throw new IllegalArgumentException("InputFormat must not be null.");
		}
		if (filePath == null) {
			throw new IllegalArgumentException("The file path must not be null.");
		}

		inputFormat.setFilePath(new Path(filePath));
		try {
			return createInput(inputFormat, TypeExtractor.getInputFormatTypes(inputFormat));
		}
		catch (Exception e) {
			throw new InvalidProgramException("The type returned by the input format could not be automatically determined. " +
					"Please specify the TypeInformation of the produced type explicitly by using the " +
					"'createInput(InputFormat, TypeInformation)' method instead.");
		}
	}
835185
public static Observable<Bitmap> getThumbnailFromPath(String filePath) {
    final Bitmap sourceBitmap = BitmapFactory.decodeFile(filePath);
    return Observable.fromCallable(new Func0<Bitmap>() {
      @Override
      public Bitmap call() {
        return ThumbnailUtils.
            extractThumbnail(sourceBitmap, sourceBitmap.getWidth(), sourceBitmap.getHeight());
      }
    });
  }
599970
private static String getFilePath(String defaultPath, String filePath) {
		return defaultPath+File.separator+filePath;
	}
837268
public static List<String> readLinesWithFilePathOrClasspath(
            String filePathOrClasspath) {
        return JMOptional
                .getOptional(JMFiles.readLines(filePathOrClasspath))
                .orElseGet(() -> getStringListAsOptWithClasspath(
                        filePathOrClasspath)
                        .orElseGet(Collections::emptyList));
    }
1291424
@Override
	public String getFilePath(String resourcePath) {
		String path = resourcePath.replace('/', File.separatorChar);
		return new File(baseDir, path).getAbsolutePath();
	}
143293
public static File getFileForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            return new File(new File(path.getPath()), resourcePath);
        }

        return new File(path.getPath());
    }
172332
Stream<String> getRessourceLines(Class<?> clazz, String filepath) {
        try (final BufferedReader fileReader = new BufferedReader(
                new InputStreamReader(clazz.getResourceAsStream(filepath),
                StandardCharsets.UTF_8)
        )) {
            // Collect the read lines before converting back to a Java stream
            // so that we can ensure that we close the InputStream and prevent leaks
            return fileReader.lines().collect(Collectors.toList()).stream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }