本文整理了Java中org.agrona.IoUtil.fill()
方法的一些代码示例,展示了IoUtil.fill()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil.fill()
方法的具体详情如下:
包路径:org.agrona.IoUtil
类名称:IoUtil
方法名:fill
[英]Fill a region of a file with a given byte value.
[中]用给定的字节值填充文件的一个区域。
代码示例来源:origin: real-logic/agrona
/**
* Create an empty file, and optionally fill with 0s, and return the {@link FileChannel}
*
* @param file to create
* @param length of the file to create
* @param fillWithZeros to the length of the file to force allocation.
* @return {@link java.nio.channels.FileChannel} for the file
*/
public static FileChannel createEmptyFile(final File file, final long length, final boolean fillWithZeros)
{
ensureDirectoryExists(file.getParentFile(), file.getParent());
FileChannel templateFile = null;
try
{
final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
randomAccessFile.setLength(length);
templateFile = randomAccessFile.getChannel();
if (fillWithZeros)
{
fill(templateFile, 0, length, (byte)0);
}
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return templateFile;
}
代码示例来源:origin: org.agrona/Agrona
/**
* Create an empty file, fill with 0s, and return the {@link FileChannel}
*
* @param file to create
* @param length of the file to create
* @return {@link java.nio.channels.FileChannel} for the file
*/
public static FileChannel createEmptyFile(final File file, final long length)
{
ensureDirectoryExists(file.getParentFile(), file.getParent());
FileChannel templateFile = null;
try
{
final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
randomAccessFile.setLength(length);
templateFile = randomAccessFile.getChannel();
fill(templateFile, 0, length, (byte)0);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return templateFile;
}
代码示例来源:origin: org.agrona/agrona
/**
* Create an empty file, and optionally fill with 0s, and return the {@link FileChannel}
*
* @param file to create
* @param length of the file to create
* @param fillWithZeros to the length of the file to force allocation.
* @return {@link java.nio.channels.FileChannel} for the file
*/
public static FileChannel createEmptyFile(final File file, final long length, final boolean fillWithZeros)
{
ensureDirectoryExists(file.getParentFile(), file.getParent());
FileChannel templateFile = null;
try
{
final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
randomAccessFile.setLength(length);
templateFile = randomAccessFile.getChannel();
if (fillWithZeros)
{
fill(templateFile, 0, length, (byte)0);
}
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return templateFile;
}
内容来源于网络,如有侵权,请联系作者删除!