本文整理了Java中org.modeshape.common.util.IoUtil
类的一些代码示例,展示了IoUtil
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil
类的具体详情如下:
包路径:org.modeshape.common.util.IoUtil
类名称:IoUtil
[英]A set of utilities for more easily performing I/O.
[中]用于更容易执行I/O的一组实用程序。
代码示例来源:origin: org.modeshape/modeshape-common
/**
* Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished
* reading.
*
* @param stream the streamed contents; may be null
* @return the contents, or an empty string if the supplied stream is null
* @throws IOException if there is an error reading the content
*/
public static String read( InputStream stream ) throws IOException {
return IoUtil.read(stream);
}
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*
* @see org.modeshape.graph.property.Binary#getBytes()
*/
public byte[] getBytes() {
try {
return IoUtil.readBytes(file);
} catch (IOException e) {
throw new IoException(e);
}
}
代码示例来源: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: ModeShape/modeshape
private InputStream getInputStreamForFile( String cndFileString ) {
return IoUtil.getResourceAsStream(cndFileString,
repository.environment().getClassLoader(this),
null);
}
代码示例来源:origin: ModeShape/modeshape
return this.getString().equals(that.getString());
case PropertyType.BINARY:
return IoUtil.isSame(this.getStream(), that.getBinary().getStream());
case PropertyType.BOOLEAN:
return this.getBoolean() == that.getBoolean();
代码示例来源:origin: org.fcrepo/modeshape-jcr
private InputStream getInputStreamForFile( String cndFileString ) {
return IoUtil.getResourceAsStream(cndFileString,
repository.environment().getClassLoader(this),
null);
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
return this.getString().equals(that.getString());
case PropertyType.BINARY:
return IoUtil.isSame(this.getStream(), that.getBinary().getStream());
case PropertyType.BOOLEAN:
return this.getBoolean() == that.getBoolean();
代码示例来源:origin: ModeShape/modeshape
/**
* Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished
* reading.
*
* @param reader the reader of the contents; may be null
* @return the contents, or an empty string if the supplied reader is null
* @throws IOException if there is an error reading the content
*/
public static String read( Reader reader ) throws IOException {
return IoUtil.read(reader);
}
代码示例来源:origin: ModeShape/modeshape
public InMemoryTestBinary( InputStream is ) throws IOException {
this(IoUtil.readBytes(is));
}
代码示例来源: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.fcrepo/modeshape-jcr
private InputStream getInitialContentFileStream( String workspaceName ) {
String initialContentFileString = initialContentConfig.getInitialContentFile(workspaceName);
InputStream stream = IoUtil.getResourceAsStream(initialContentFileString,
repository.environment().getClassLoader(this),
null);
if (stream == null) {
repository.warn(JcrI18n.cannotLoadInitialContentFile, initialContentFileString);
}
return stream;
}
代码示例来源:origin: org.modeshape/modeshape-common
/**
* Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished
* reading.
*
* @param reader the reader of the contents; may be null
* @return the contents, or an empty string if the supplied reader is null
* @throws IOException if there is an error reading the content
*/
public static String read( Reader reader ) throws IOException {
return IoUtil.read(reader);
}
代码示例来源:origin: org.modeshape/modeshape-common
/**
* Read and return the entire contents of the supplied {@link File file}.
*
* @param file the file containing the contents; may be null
* @return the contents, or an empty byte array if the supplied file is null
* @throws IOException if there is an error reading the content
*/
public static byte[] readBytes( File file ) throws IOException {
if (file == null) return new byte[] {};
InputStream stream = new BufferedInputStream(new FileInputStream(file));
boolean error = false;
try {
return readBytes(stream);
} catch (IOException e) {
error = true; // this error should be thrown, even if there is an error closing stream
throw e;
} catch (RuntimeException e) {
error = true; // this error should be thrown, even if there is an error closing stream
throw e;
} finally {
try {
stream.close();
} catch (IOException e) {
if (!error) throw e;
}
}
}
代码示例来源: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: ModeShape/modeshape
private InputStream getInitialContentFileStream( String workspaceName ) {
String initialContentFileString = initialContentConfig.getInitialContentFile(workspaceName);
InputStream stream = IoUtil.getResourceAsStream(initialContentFileString,
repository.environment().getClassLoader(this),
null);
if (stream == null) {
repository.warn(JcrI18n.cannotLoadInitialContentFile, initialContentFileString);
}
return stream;
}
代码示例来源:origin: org.fcrepo/modeshape-common
/**
* Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished
* reading.
*
* @param reader the reader of the contents; may be null
* @return the contents, or an empty string if the supplied reader is null
* @throws IOException if there is an error reading the content
*/
public static String read( Reader reader ) throws IOException {
return IoUtil.read(reader);
}
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*
* @see org.modeshape.graph.property.BinaryFactory#create(java.io.File)
*/
public Binary create( File file ) throws ValueFormatException, IoException {
if (file == null) return null;
if (!file.canRead()) return null;
if (!file.isFile()) return null;
try {
byte[] value = IoUtil.readBytes(file);
return create(value);
} catch (IOException err) {
throw new IoException(GraphI18n.errorConvertingIo.text(file, Binary.class.getSimpleName()), err);
}
}
代码示例来源: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: org.fcrepo/modeshape-common
/**
* Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when finished
* reading.
*
* @param stream the streamed contents; may be null
* @return the contents, or an empty string if the supplied stream is null
* @throws IOException if there is an error reading the content
*/
public static String read( InputStream stream ) throws IOException {
return IoUtil.read(stream);
}
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*/
public Binary create( InputStream stream,
long approximateLength ) throws IoException {
if (stream == null) return null;
try {
byte[] value = IoUtil.readBytes(stream);
return create(value);
} catch (IOException err) {
throw new IoException(GraphI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
Binary.class.getSimpleName()), err);
}
}
内容来源于网络,如有侵权,请联系作者删除!