class Source {

  @VisibleForTesting
  static Charset getCharSet(File file) {
    long bufferSize = file.length() < 9999 ? file.length() : 9999;
    byte[] buffer = new byte[(int) bufferSize];
    try (InputStream initialStream = new FileInputStream(file)) {
      int bytesRead = initialStream.read(buffer);
      if (bytesRead < bufferSize) {
        throw new IOException("Was not able to read expected number of bytes");
      }
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    return getCharSet(buffer);
  }

  public  Source(File file);
  public  Source(File file, Charset charset);
  public  Source(Reader reader);
  public  Source(InputStream inputStream);
  public  Source(InputStream inputStream, Charset charset);

}