本文整理了Java中org.agrona.IoUtil.checkFileExists()
方法的一些代码示例,展示了IoUtil.checkFileExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil.checkFileExists()
方法的具体详情如下:
包路径:org.agrona.IoUtil
类名称:IoUtil
方法名:checkFileExists
[英]Check that a file exists and throw an exception if not.
[中]检查文件是否存在,如果不存在,则引发异常。
代码示例来源:origin: real-logic/agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for entire file
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for any exceptions
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(final File location, final String descriptionLabel)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, 0, channel.size());
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
代码示例来源:origin: real-logic/agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for only region specified
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for an exceptions
* @param offset offset to start mapping at
* @param length length to map region
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(
final File location, final String descriptionLabel, final long offset, final long length)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, offset, length);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
代码示例来源:origin: real-logic/artio
private void openFile(final File file)
{
checkFileExists(file, file.getName());
try
{
final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
channel = randomAccessFile.getChannel();
map(channel.size());
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
}
代码示例来源:origin: org.agrona/agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for only region specified
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for an exceptions
* @param offset offset to start mapping at
* @param length length to map region
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(
final File location, final String descriptionLabel, final long offset, final long length)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, offset, length);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
代码示例来源:origin: org.agrona/agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for entire file
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for any exceptions
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(final File location, final String descriptionLabel)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, 0, channel.size());
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
代码示例来源:origin: org.agrona/Agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for entire file
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for any exceptions
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(final File location, final String descriptionLabel)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, 0, channel.size());
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
代码示例来源:origin: org.agrona/Agrona
/**
* Check that file exists, open file, and return MappedByteBuffer for only region specified
* <p>
* The file itself will be closed, but the mapping will persist.
*
* @param location of the file to map
* @param descriptionLabel to be associated for an exceptions
* @param offset offset to start mapping at
* @param size length to map region
* @return {@link java.nio.MappedByteBuffer} for the file
*/
public static MappedByteBuffer mapExistingFile(
final File location, final String descriptionLabel, final long offset, final long size)
{
checkFileExists(location, descriptionLabel);
MappedByteBuffer mappedByteBuffer = null;
try (RandomAccessFile file = new RandomAccessFile(location, "rw");
FileChannel channel = file.getChannel())
{
mappedByteBuffer = channel.map(READ_WRITE, offset, size);
}
catch (final IOException ex)
{
LangUtil.rethrowUnchecked(ex);
}
return mappedByteBuffer;
}
内容来源于网络,如有侵权,请联系作者删除!