jodd.io.FileUtil.unicodeInputStreamOf()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中jodd.io.FileUtil.unicodeInputStreamOf()方法的一些代码示例,展示了FileUtil.unicodeInputStreamOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.unicodeInputStreamOf()方法的具体详情如下:
包路径:jodd.io.FileUtil
类名称:FileUtil
方法名:unicodeInputStreamOf

FileUtil.unicodeInputStreamOf介绍

暂无

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Returns either new {@link FileInputStream} or new {@link UnicodeInputStream}.
 *
 * @return either {@link FileInputStream} or {@link UnicodeInputStream}.
 * @throws IOException if something went wrong.
 * @see #unicodeInputStreamOf(InputStream, String)
 */
private static InputStream streamOf(final File file, final String encoding) throws IOException {
  InputStream in = new FileInputStream(file);
  if (encoding.startsWith("UTF")) {
    in = unicodeInputStreamOf(in, encoding);
  }
  return in;
}

代码示例来源:origin: oblac/jodd

/**
 * @see #unicodeInputStreamOf(InputStream, String)
 * @see #checkExists(File)
 * @see #checkIsFile(File)
 */
private static UnicodeInputStream unicodeInputStreamOf(final File file) throws IOException {
  checkExists(file);
  checkIsFile(file);
  return unicodeInputStreamOf(new FileInputStream(file), null);
}

代码示例来源:origin: oblac/jodd

/**
 * Detects optional BOM and reads UTF {@link String} from a {@link File}.
 * If BOM is missing, UTF-8 is assumed.
 *
 * @param file {@link File} to read.
 * @return String in UTF encoding.
 * @throws IOException if copy to {@link InputStream} errors.
 * @see #unicodeInputStreamOf(File)
 * @see StreamUtil#copy(InputStream, String)
 */
public static String readUTFString(final File file) throws IOException {
  UnicodeInputStream in = unicodeInputStreamOf(file);
  try {
    return StreamUtil.copy(in, detectEncoding(in)).toString();
  } finally {
    StreamUtil.close(in);
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Reads UTF file content as char array.
 *
 * @param file {@link File} to read.
 * @return array of characters.
 * @throws IOException if something went wrong.
 */
public static char[] readUTFChars(final File file) throws IOException {
  checkExists(file);
  checkIsFile(file);
  UnicodeInputStream in = unicodeInputStreamOf(file);
  try {
    return StreamUtil.readChars(in, detectEncoding(in));
  } finally {
    StreamUtil.close(in);
  }
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Returns either new {@link FileInputStream} or new {@link UnicodeInputStream}.
 *
 * @return either {@link FileInputStream} or {@link UnicodeInputStream}.
 * @throws IOException if something went wrong.
 * @see #unicodeInputStreamOf(InputStream, String)
 */
private static InputStream streamOf(final File file, final String encoding) throws IOException {
  InputStream in = new FileInputStream(file);
  if (encoding.startsWith("UTF")) {
    in = unicodeInputStreamOf(in, encoding);
  }
  return in;
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #unicodeInputStreamOf(InputStream, String)
 * @see #checkExists(File)
 * @see #checkIsFile(File)
 */
private static UnicodeInputStream unicodeInputStreamOf(final File file) throws IOException {
  checkExists(file);
  checkIsFile(file);
  return unicodeInputStreamOf(new FileInputStream(file), null);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Detects optional BOM and reads UTF {@link String} from a {@link File}.
 * If BOM is missing, UTF-8 is assumed.
 *
 * @param file {@link File} to read.
 * @return String in UTF encoding.
 * @throws IOException if copy to {@link InputStream} errors.
 * @see #unicodeInputStreamOf(File)
 * @see StreamUtil#copy(InputStream, String)
 */
public static String readUTFString(final File file) throws IOException {
  UnicodeInputStream in = unicodeInputStreamOf(file);
  try {
    return StreamUtil.copy(in, detectEncoding(in)).toString();
  } finally {
    StreamUtil.close(in);
  }
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Reads UTF file content as char array.
 *
 * @param file {@link File} to read.
 * @return array of characters.
 * @throws IOException if something went wrong.
 */
public static char[] readUTFChars(final File file) throws IOException {
  checkExists(file);
  checkIsFile(file);
  UnicodeInputStream in = unicodeInputStreamOf(file);
  try {
    return StreamUtil.readChars(in, detectEncoding(in));
  } finally {
    StreamUtil.close(in);
  }
}

相关文章