计算文件内容的etag

@param file 文件对象
@return 文件内容的etag
@throws IOException 文件读取异常
182719
public static String file(File file) throws IOException {
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            return stream(in, file.length());
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
540040
public static String readFile(File file) {
		FileInputStream inputStream;
		try {
			inputStream = new FileInputStream(file);
			return new String(readStream(inputStream));
		} catch (FileNotFoundException e) {
			JK.throww(e);
			return null;
		}
	}
543908
public static ArrayList<Line> getLinesInTextFile(String encoding, File file) throws IOException {
		ArrayList<Line> lines = new ArrayList<Line>();
		FileInputStream inputStream = new FileInputStream(file);
		InputStreamReader inputReader = null;
		if(encoding != null) {
			inputReader = new InputStreamReader(inputStream, encoding);
		} else {
			inputReader = new InputStreamReader(inputStream);
		}
		//FileReader fileReader = new FileReader(file);
		BufferedReader reader = new BufferedReader(inputReader);
		String line; int count = 0;
		while ((line = reader.readLine()) != null) {
			count++;
			lines.add(new Line(file.getName(), count, line));
		}
		reader.close();
		return lines;
	}
257679
public static String read(final File file) throws IOException {
        final StringBuilder sb = new StringBuilder();

        try (
                final FileReader fr = new FileReader(file);
                final BufferedReader br = new BufferedReader(fr);
        ) {

            String sCurrentLine;

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        }

        return sb.toString();
    }
734033
@Nonnull
    public static String getDigestOf(@Nonnull File file) throws IOException {
        // Note: getDigestOf() closes the input stream.
        return getDigestOf(Files.newInputStream(fileToPath(file)));
    }
624568
public String guessContentTypeFromFile(File file) {
        String contentType = URLConnection.guessContentTypeFromName(file.getName());
        if (contentType == null) {
            return "application/octet-stream";
        } else {
            return contentType;
        }
    }
617403
public ZipFile getZipFile(final File file) throws IOException {
        try {
            if (System.getSecurityManager() == null)
                return new ZipFile(file);
            try {
                return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() {
                    @Override
                    public ZipFile run() throws IOException {
                        return new ZipFile(file);
                    }
                }, controlContext);
            } catch (PrivilegedActionException e) {
                if (e.getException() instanceof IOException)
                    throw (IOException) e.getException();
                throw (RuntimeException) e.getException();
            }
        } catch (ZipException e) {
            ZipException zipNameException = new ZipException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$
            zipNameException.initCause(e);
            throw zipNameException;
        } catch (IOException e) {
            throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$
        }
    }
1206847
public static String getFileMD5String(File file) throws IOException {
        MessageDigest messageDigest = getMessageDigest(MD5);
        return getFileHashString(file, messageDigest);
    }
1020977
public Toml read(File file) {
    try {
      return read(new InputStreamReader(new FileInputStream(file), "UTF8"));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
829382
@Nonnull
    public static String readFile(@Nonnull File file, @Nonnull String charset) throws IOException {
        return readFile(file, Charset.forName(charset));
    }
1162282
public static byte[] readBytes(File file) throws IOException {
        byte[] bytes = new byte[(int) file.length()];
        FileInputStream fileInputStream = new FileInputStream(file);
        DataInputStream dis = new DataInputStream(fileInputStream);
        try {
            dis.readFully(bytes);
            InputStream temp = dis;
            dis = null;
            temp.close();
        } finally {
            closeWithWarning(dis);
        }
        return bytes;
    }
848131
public Set<FileAnnotation> parse(final InputStream file) throws IOException {
        try {
            Set<FileAnnotation> allAnnotations = Sets.newHashSet();
            for (AbstractWarningsParser parser : parsers) {
                allAnnotations.addAll(parser.parse(createReader(file)));
            }
            return applyExcludeFilter(allAnnotations);
        }
        finally {
            IOUtils.closeQuietly(file);
        }
    }
220143
public static String slurpGZippedFile(File file) throws IOException {
    Reader r = new InputStreamReader(new GZIPInputStream(new FileInputStream(
        file)));
    return IOUtils.slurpReader(r);
  }
294838
public static List<String> toLines(final File file) throws IOException {
		return Files.readAllLines(file.toPath(), Charsets.UTF_8);
	}
506411
public static String read(File file, String encoding) throws IOException {
        Reader reader = getReader(file, encoding);
        String source;
        try {
            source = read(reader);
        } finally {
            reader.close();
        }
        return source;
    }
131168
public static final String getGroup(Path file) throws IOException
    {
        if (supports("posix"))
        {
            PosixFileAttributeView view = Files.getFileAttributeView(file, PosixFileAttributeView.class);
            PosixFileAttributes attrs = view.readAttributes();
            GroupPrincipal group = attrs.group();
            return group.getName();
        }
        else
        {
            JavaLogging.getLogger(PosixHelp.class).warning("no posix support. getGroup(%s) returns \"\"", file);
            return "";
        }
    }
695621
public static Hml read(final File file) throws IOException {
        checkNotNull(file);
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            return read(reader);
        }
    }