Convenience method to call {@link #getExistingFile(String)} and then apply {@link
FileUtils#loadSymbolSet(CharSource)} on it, if the param is present. If the param is missing,
{@link Optional#absent()} is returned.
161350
public Optional<ImmutableSet<Symbol>> getOptionalFileAsSymbolSet(String param)
      throws IOException {
    if (isPresent(param)) {
      return Optional
          .of(FileUtils.loadSymbolSet(Files.asCharSource(getExistingFile(param), Charsets.UTF_8)));
    } else {
      return Optional.absent();
    }
  }
1082634
public static boolean isEmpty(final File file, final Charset charset) throws IOException {
		boolean empty = false;
		BufferedReader reader = null;
		boolean threw = true;
		try {
			reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
			final String line = reader.readLine();
			empty = line == null;
			threw = false;
		} finally {
			Closeables.close(reader, threw);
		}
		return empty;
	}
934554
public ImmutableList<String> getFileAsStringList(String param) throws IOException {
    return FileUtils.loadStringList(Files.asCharSource(getExistingFile(param), Charsets.UTF_8));
  }
748863
public static File exists(File file) {
		Validate.notNull(file);
		if(!file.exists())
			throw new ParameterException("\""+file+"\" does not exist!");
		return file;
	}
225899
private Path getPath(String fileName)
      throws IOException, URISyntaxException {
    Path path;
    URL url = getClass().getClassLoader().getResource(fileName);
    if (url == null) {
      throw new IOException(String.format("File %s is not existing", fileName));
    }
    URI uri = url.toURI();
    Map<String, String> env = new HashMap<>();
    if (uri.toString().contains("!")) {
      String[] parts = uri.toString().split("!");
      if (fs == null) {
        fs = FileSystems.newFileSystem(URI.create(parts[0]), env);
      }
      path = fs.getPath(parts[1]);
    } else {
      path = Paths.get(uri);
    }
    return path;
  }
705550
public static XMLStreamException missingRequired(final XMLExtendedStreamReader reader, final String... required) {
        final StringBuilder b = new StringBuilder();
        for (int i = 0; i < required.length; i++) {
            final String o = required[i];
            b.append(o);
            if (required.length > i + 1) {
                b.append(", ");
            }
        }

        return wrapMissingRequiredAttribute(ControllerLogger.ROOT_LOGGER.missingRequiredAttributes(b, reader.getLocation()),
                                            reader, new HashSet<>(Arrays.asList(required)));
    }
887260
private static FileResource getFileResourceProto(final String fileName, final FileType type) throws IOException {
    File file = new File(fileName);
    if (file.exists()) {
      // It is a local file and can be added.
      if (file.isDirectory()) {
        // If it is a directory, create a JAR file of it and add that instead.
        file = toJar(file);
      }
      return FileResourceImpl.newBuilder()
          .setName(file.getName())
          .setPath(file.getPath())
          .setType(type)
          .build();
    } else {
      // The file isn't in the local filesytem. Assume that the file is actually a URI.
      // We then assume that the underlying resource manager knows how to deal with it.
      try {
        final URI uri = new URI(fileName);
        final String path = uri.getPath();
        final String name = path.substring(path.lastIndexOf('/') + 1);
        return FileResourceImpl.newBuilder()
            .setName(name)
            .setPath(uri.toString())
            .setType(type)
            .build();
      } catch (final URISyntaxException e) {
        throw new IOException("Unable to parse URI.", e);
      }
    }
  }
477204
public static Map<String, File> loadStringToFileMap(final CharSource source) throws IOException {
    return loadMap(source, Functions.<String>identity(), FileFunction.INSTANCE,
        IsCommentLine.INSTANCE);
  }
1077928
public CharSequence readSource(JavaFileObject filename) {
        try {
            inputFiles.add(filename);
            return filename.getCharContent(false);
        } catch (IOException e) {
            log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
            return null;
        }
    }
579018
public static String getIor(String filename) throws FileNotFoundException, SecurityException, IOException {
		FileInputStream fid = new FileInputStream(filename);
		int nb = fid.available();
		byte[] inStr = new byte[nb];
		int	nbread = fid.read(inStr);
		fid.close();
		String	str = "";
		if (nbread>0)
			str = new String(inStr);
		System.out.println(str);
		return str.trim();
	}
707202
@SuppressWarnings("rawtypes")
    @Override
    public boolean getIsEmpty() {

        if (m_object == null) {
            // this is the case for non existing values
            return true;
        } else if (m_object instanceof String) {
            // return values for String
            return CmsStringUtil.isEmpty((String)m_object);
        } else if (m_object instanceof Collection) {
            // if a collection has any entries it is not emtpy
            return !((Collection)m_object).isEmpty();
        } else {
            // assume all other non-null objects are not empty
            return false;
        }
    }
406169
void loadScript(Charset charset) throws IOException {
		this.charset = charset;
		StringBuilder sb = new StringBuilder();
		try (BufferedReader br = Files.newBufferedReader(file.toPath(), charset)) {
			int len;
			char[] buf = new char[1024];
			while ((len = br.read(buf)) != -1) {
				sb.append(buf, 0, len);
			}
		}
		setContents(sb.toString());
		setChanged(false);
		this.lastModified = file.lastModified();
	}
762417
private void checkFileDataSource(FileDataSourceBase<?> fileSource) {
		String path = fileSource.getFilePath();
		if (path == null) {
			throw new InvalidProgramException("File path of FileDataSource is null.");
		}
		if (path.length() == 0) {
			throw new InvalidProgramException("File path of FileDataSource is empty string.");
		}
		
		try {
			Path p = new Path(path);
			String scheme = p.toUri().getScheme();
			
			if (scheme == null) {
				throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource has no file system scheme (like 'file:// or hdfs://').");
			}
		} catch (Exception e) {
			throw new InvalidProgramException("File path \"" + path + "\" of FileDataSource is an invalid path: " + e.getMessage());
		}
	}
205341
@NullSafe
  public static File assertExists(File path) throws FileNotFoundException {
    if (isExisting(path)) {
      return path;
    }

    throw new FileNotFoundException(String.format("[%1$s] was not found", path));
  }
268455
public String loadAsString() throws IOException {
        long sizeGuess;
        if(file.exists())
            sizeGuess = file.length();
        else
        if(gz.exists())
            sizeGuess = gz.length()*2;
        else
            return "";

        StringBuilder str = new StringBuilder((int)sizeGuess);

        try (InputStream is = read();
             Reader r = new InputStreamReader(is)) {
            char[] buf = new char[8192];
            int len;
            while((len=r.read(buf,0,buf.length))>0)
                str.append(buf,0,len);
        }

        return str.toString();
    }
96852
public Optional<InputStream> getFile() {
        if (!this.files.isEmpty()) {
            return Optional.of(this.files.get(0));
        }

        return Optional.empty();
    }
461227
private static File findFileOption(String[] args, String option, String name, boolean needed)
        throws ProblemException, ProblemException {
        File file = null;
        for (int i = 0; i<args.length; ++i) {
            if (args[i].equals(option)) {
                if (file != null) {
                    throw new ProblemException("You have already specified the "+name+" file!");
                }
                if (i+1 >= args.length) {
                    throw new ProblemException("You have to specify a file following "+option+".");
                }
                file = new File(args[i+1]);
                if (file.isDirectory()) {
                    throw new ProblemException("\""+args[i+1]+"\" is not a file.");
                }
                if (!file.exists() && needed) {
                    throw new ProblemException("The file \""+args[i+1]+"\" does not exist.");
                }

            }
        }
        if (file == null && needed) {
            throw new ProblemException("You have to specify "+option);
        }
        return file;
    }