org.modeshape.common.util.IoUtil.write()方法的使用及代码示例

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

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

IoUtil.write介绍

[英]Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when finished.
[中]将所提供字符串的全部内容写入给定流。完成时,此方法始终刷新并关闭流。

代码示例

代码示例来源:origin: org.modeshape/modeshape-common

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param input the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( InputStream input,
             OutputStream stream ) throws IOException {
  write(input, stream, 1024);
}

代码示例来源:origin: org.modeshape/modeshape-common

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param content the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( String content,
             OutputStream stream ) throws IOException {
  IoUtil.write(content, stream);
}

代码示例来源:origin: org.modeshape/modeshape-common

/**
 * Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
 * finished.
 * 
 * @param content the content to write to the writer; may be null
 * @param writer the writer to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the writer is null
 */
public static void write( String content,
             Writer writer ) throws IOException {
  IoUtil.write(content, writer);
}

代码示例来源:origin: org.fcrepo/modeshape-common

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param input the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( InputStream input,
             OutputStream stream ) throws IOException {
  write(input, stream, 1024);
}

代码示例来源:origin: ModeShape/modeshape

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param content the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( String content,
             OutputStream stream ) throws IOException {
  IoUtil.write(content, stream);
}

代码示例来源:origin: org.fcrepo/modeshape-common

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param content the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( String content,
             OutputStream stream ) throws IOException {
  IoUtil.write(content, stream);
}

代码示例来源:origin: org.fcrepo/modeshape-common

/**
 * Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
 * finished.
 * 
 * @param content the content to write to the writer; may be null
 * @param writer the writer to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the writer is null
 */
public static void write( String content,
             Writer writer ) throws IOException {
  IoUtil.write(content, writer);
}

代码示例来源:origin: ModeShape/modeshape

/**
 * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
 * finished.
 * 
 * @param input the content to write to the stream; may be null
 * @param stream the stream to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the stream is null
 */
public static void write( InputStream input,
             OutputStream stream ) throws IOException {
  write(input, stream, 1024);
}

代码示例来源:origin: ModeShape/modeshape

/**
 * Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
 * finished.
 * 
 * @param content the content to write to the writer; may be null
 * @param writer the writer to which the content is to be written
 * @throws IOException
 * @throws IllegalArgumentException if the writer is null
 */
public static void write( String content,
             Writer writer ) throws IOException {
  IoUtil.write(content, writer);
}

代码示例来源:origin: ModeShape/modeshape-examples

private static void createFile( File parent,
                  String path ) throws Exception {
    File file = new File(parent, path);
    IoUtil.write(new ByteArrayInputStream("some content".getBytes()), new FileOutputStream(file));
  }
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

/**
 * Converts input stream into ByteBuffer.
 * 
 * @param stream
 * @return the byte buffer
 * @throws IOException
 */
private ByteBuffer buffer( InputStream stream ) throws IOException {
  stream.reset();
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  IoUtil.write(stream, bout);
  return ByteBuffer.wrap(bout.toByteArray());
}

代码示例来源:origin: ModeShape/modeshape

/**
 * Converts input stream into ByteBuffer.
 * 
 * @param stream
 * @return the byte buffer
 * @throws IOException
 */
private ByteBuffer buffer( InputStream stream ) throws IOException {
  stream.reset();
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  IoUtil.write(stream, bout);
  return ByteBuffer.wrap(bout.toByteArray());
}

代码示例来源:origin: ModeShape/modeshape

private void writeProperties( File propertiesFile,
               Map<String, Object> properties ) throws IOException {
  StringBuilder content = new StringBuilder();
  for (Iterator<Map.Entry<String, Object>> it = properties.entrySet().iterator(); it.hasNext();) {
    Map.Entry<String, Object> entry = it.next();
    content.append(entry.getKey()).append("=").append(valueToString(entry.getValue()));
    if (it.hasNext()) {
      content.append(";");
    }
  }
  IoUtil.write(content.toString(), propertiesFile);
}

代码示例来源:origin: ModeShape/modeshape

private void storeStringAtKey( String string,
                BinaryKey key) throws BinaryStoreException {
  File tmpFile = null;
  try {
    tmpFile = File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX + EXTRACTED_TEXT_SUFFIX);
    IoUtil.write(string, new BufferedOutputStream(new FileOutputStream(tmpFile)));
    saveTempFileToStore(tmpFile, key, tmpFile.length());
  } catch (IOException e) {
    throw new BinaryStoreException(e);
  } finally {
    if (tmpFile != null) {
      tmpFile.delete();
    }
  }
}

代码示例来源:origin: ModeShape/modeshape

protected static void addFile( File directory,
                String path,
                String contentFile ) throws IOException {
  File file = new File(directory, path);
  IoUtil.write(FileSystemConnectorTest.class.getClassLoader().getResourceAsStream(contentFile), new FileOutputStream(file));
}

代码示例来源:origin: ModeShape/modeshape

private void addFile( String path,
             String contentFile ) throws IOException {
    File file = new File(directory, path);
    IoUtil.write(getClass().getClassLoader().getResourceAsStream(contentFile), new FileOutputStream(file));
  }
}

代码示例来源:origin: ModeShape/modeshape

public void initialize() throws IOException {
  if (directory.exists()) FileUtil.delete(directory);
  directory.mkdirs();
  // Make some content ...
  new File(directory, "dir1").mkdir();
  new File(directory, "dir2").mkdir();
  new File(directory, "dir3").mkdir();
  File simpleJson = new File(directory, "dir3/simple.json");
  IoUtil.write(getClass().getClassLoader().getResourceAsStream("data/simple.json"), new FileOutputStream(simpleJson));
  File simpleTxt = new File(directory, "dir3/simple.txt");
  IoUtil.write(TEXT_CONTENT, new FileOutputStream(simpleTxt));
}

代码示例来源:origin: ModeShape/modeshape

private void prepareExternalDirectory( String dirpath ) throws IOException {
  FileUtil.delete(dirpath);
  new File(dirpath).mkdir();
  File file = new File(dirpath + "/file.txt");
  IoUtil.write(JcrRepositoryStartupTest.class.getClassLoader().getResourceAsStream("io/file1.txt"),
         new FileOutputStream(file));
}

代码示例来源:origin: ModeShape/modeshape

@Before
public void before() throws Exception {
  FileUtil.delete("target/files");
  File fileConnectorTestDir = new File("target/files");
  fileConnectorTestDir.mkdir();
  File testFile = new File(fileConnectorTestDir, "testFile");
  IoUtil.write(getClass().getClassLoader().getResourceAsStream("data/simple.json"), new FileOutputStream(testFile));
}

代码示例来源:origin: ModeShape/modeshape

private void readLargeBinary() throws Exception {
  Node commit = session.getNode("/repos/git-modeshape-remote/tree/master/modeshape-jcr/src/test/resources/docs/postgresql-8.4.1-US.pdf");
  assertNotNull(commit);
  Binary data = commit.getNode("jcr:content").getProperty("jcr:data").getBinary();
  long size = data.getSize();
  assertTrue(size > 0);
  //simply read the stream to make sure it's valid
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  BufferedOutputStream bos = new BufferedOutputStream(baos);
  IoUtil.write(data.getStream(), bos);
  assertEquals("invalid binary stream", size, baos.toByteArray().length);
}

相关文章