info.aduna.io.IOUtil类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(172)

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

IOUtil介绍

[英]Utility methods for I/O working with Readers, Writers, InputStreams and OutputStreams.
[中]用于处理读卡器、写入器、输入流和输出流的I/O的实用方法。

代码示例

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static String readString(InputStream in)
  throws IOException
{
  return readString(new InputStreamReader(in));
}

代码示例来源:origin: blazegraph/database

private void prepareForWire() throws Exception {
  
  if (file != null) {
    // set the data
    data = IOUtil.readBytes(file);
    
  } else if (is != null) {
    // set the data
    data = IOUtil.readBytes(is);
    
  } else if (reader != null) {
    // set the data
    data = IOUtil.readString(reader).getBytes();
    
  } else if (stmts != null) {
    
    // set the data and content type (TRIG by default)
    format = RDFFormat.TRIG;
    data = serialize(stmts, format);
  }
  
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static void writeBytes(byte[] data, OutputStream out)
  throws IOException
{
  transfer(new ByteArrayInputStream(data), out);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static String readString(URL url)
  throws IOException
{
  Reader reader = urlToReader(url);
  try {
    return readString(reader);
  }
  finally {
    reader.close();
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static boolean isZipStream(InputStream in)
  throws IOException
{
  in.mark(MAGIC_NUMBER.length);
  byte[] fileHeader = IOUtil.readBytes(in, MAGIC_NUMBER.length);
  in.reset();
  return Arrays.equals(MAGIC_NUMBER, fileHeader);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Read properties from the specified InputStream.
 * 
 * @param in
 *        the stream to read from. The stream will be closed by this method.
 * @return Properties loaded from the specified stream. The stream will be
 *         closed by this method.
 * @throws IOException
 *         when the stream could not be read properly
 */
public static Properties readProperties(InputStream in)
  throws IOException
{
  return readProperties(in, null);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Write the specified properties to the specified file.
 * 
 * @param props
 *        the properties to write
 * @param file
 *        the file to write to
 * @throws IOException
 *         when the properties could not be written to the file properly
 */
public static void writeProperties(Properties props, File file, boolean includeDefaults)
  throws IOException
{
  writeProperties(props, new FileOutputStream(file), includeDefaults);
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

public static boolean isGZipStream(InputStream in)
    throws IOException
  {
    in.mark(MAGIC_NUMBER.length);
    byte[] fileHeader = IOUtil.readBytes(in, MAGIC_NUMBER.length);
    in.reset();
    return Arrays.equals(MAGIC_NUMBER, fileHeader);
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Read properties from the specified file.
 * 
 * @param propsFile
 *        the file to read from
 * @return Properties loaded from the specified file
 * @throws IOException
 *         when the file could not be read properly
 */
public static Properties readProperties(File propsFile)
  throws IOException
{
  return readProperties(propsFile, null);
}

代码示例来源:origin: info.aduna.appbase/aduna-appbase-core

/**
   * Save configuration properties to a file.
   * 
   * @param props
   *        the configuration properties
   * @param file
   *        the file to write to
   * @throws IOException
   *         if the settings could not be saved because of an I/O problem
   */
  public static void saveConfigurationProperties(Properties props, File file, boolean includeDefaults)
    throws IOException
  {
    if (file.getParentFile().mkdirs() || file.getParentFile().canWrite()) {
      IOUtil.writeProperties(props, file, includeDefaults);
    }
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Read the contents as a string from the given file.
 */
public static String readString(File file)
  throws IOException
{
  FileInputStream in = new FileInputStream(file);
  try {
    return readString(in);
  }
  finally {
    in.close();
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Reads at most <tt>maxBytes</tt> bytes from the supplied input stream and
 * returns them as a byte array.
 * 
 * @param in
 *        The InputStream supplying the bytes.
 * @param maxBytes
 *        The maximum number of bytes to read from the input stream.
 * @return A byte array of size <tt>maxBytes</tt> if the input stream can
 *         produce that amount of bytes, or a smaller byte array containing
 *         all available bytes from the stream otherwise.
 */
public static byte[] readBytes(InputStream in, int maxBytes)
  throws IOException
{
  byte[] result = new byte[maxBytes];
  int bytesRead = readBytes(in, result);
  if (bytesRead < maxBytes) {
    // Create smaller byte array
    byte[] tmp = new byte[bytesRead];
    System.arraycopy(result, 0, tmp, 0, bytesRead);
    result = tmp;
  }
  return result;
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Reads all bytes from the supplied input stream and returns them as a byte
 * array.
 * 
 * @param in
 *        The InputStream supplying the bytes.
 * @return A byte array containing all bytes from the supplied input stream.
 */
public static byte[] readBytes(InputStream in)
  throws IOException
{
  ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
  transfer(in, out);
  return out.toByteArray();
}

代码示例来源:origin: info.aduna.commons/aduna-commons-io

/**
 * Read properties from the specified file.
 * 
 * @param propsFile
 *        the file to read from
 * @param defaults
 *        the default properties to use
 * @return Properties loaded from the specified file
 * @throws IOException
 *         when the file could not be read properly
 */
public static Properties readProperties(File propsFile, Properties defaults)
  throws IOException
{
  return readProperties(new FileInputStream(propsFile), defaults);
}

代码示例来源:origin: org.openrdf.sesame/sesame-config

/**
   * Save configuration properties to a file.
   * 
   * @param props
   *        the configuration properties
   * @param file
   *        the file to write to
   * @throws IOException
   *         if the settings could not be saved because of an I/O problem
   */
  public static void saveConfigurationProperties(Properties props, File file, boolean includeDefaults)
    throws IOException
  {
    if (file.getParentFile().mkdirs() || file.getParentFile().canWrite()) {
      IOUtil.writeProperties(props, file, includeDefaults);
    }
  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-config

/**
 * Load configuration settings from the specified file.
 * 
 * @param file
 *        the file to load from
 * @return the contents of the file as a String, or null if the file did not
 *         exist
 * @throws IOException
 *         if the contents of the file could not be read due to an I/O
 *         problem
 */
public static String loadConfigurationContents(File file)
  throws IOException
{
  String result = null;
  if (file.exists()) {
    result = IOUtil.readString(file);
  }
  return result;
}

代码示例来源:origin: blazegraph/database

private void prepareForWire() throws Exception {
  
  if (file != null) {
    // set the data
    data = IOUtil.readBytes(file);
    
  } else if (stmts != null) {
    
    // set the data and content type (TRIG by default)
    format = RDFFormat.TRIG;
    data = serialize(stmts, format);
  }
  
}

代码示例来源:origin: org.openrdf.sesame/sesame-http-client

public void writeTo(OutputStream out)
    throws IOException
  {
    try {
      OutputStreamWriter writer = new OutputStreamWriter(out, charset);
      IOUtil.transfer(contents, writer);
      writer.flush();
    }
    finally {
      contents.close();
    }
  }
};

代码示例来源:origin: info.aduna.appbase/aduna-appbase-core

/**
 * Load configuration properties from the specified file.
 * 
 * @param file
 *        the file to load from
 * @return the contents of the file as Properties, or null if the file did
 *         not exist
 * @throws IOException
 *         if the contents of the file could not be read due to an I/O
 *         problem
 */
public static Properties loadConfigurationProperties(File file, Properties defaults)
  throws IOException
{
  Properties result = null;
  if (file.exists()) {
    result = IOUtil.readProperties(file, defaults);
  }
  else {
    result = new Properties(defaults);
  }
  return result;
}

代码示例来源:origin: blazegraph/database

public String getQueryString() throws Exception {
  if (queryString == null) {
    InputStream stream = new URL(queryFileURL).openStream();
    try {
      return IOUtil.readString(new InputStreamReader(stream, "UTF-8"));
    }
    finally {
      stream.close();
    }
  }
  return queryString;
}

相关文章