本文整理了Java中org.agrona.IoUtil.deleteIfExists()
方法的一些代码示例,展示了IoUtil.deleteIfExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtil.deleteIfExists()
方法的具体详情如下:
包路径:org.agrona.IoUtil
类名称:IoUtil
方法名:deleteIfExists
[英]Delete file only if it already exists.
[中]仅当文件已存在时才删除该文件。
代码示例来源:origin: real-logic/agrona
@AfterClass
public static void tearDown()
{
CloseHelper.close(channel);
IoUtil.deleteIfExists(new File(PATH));
}
代码示例来源:origin: kaazing/gateway
/**
* Method creating the monitoring MMF
*/
private void createMonitoringFile() {
String monitoringDirName = getMonitoringDirName();
monitoringDir = new File(monitoringDirName);
File monitoringFile = new File(monitoringDir, gatewayId);
IoUtil.deleteIfExists(monitoringFile);
monitorFileWriter.initialize(monitoringFile);
}
代码示例来源:origin: real-logic/artio
private void deleteFiles()
{
deleteIfExists(new File(INDEX_FILE_PATH));
deleteIfExists(writablePath(INDEX_FILE_PATH));
deleteIfExists(passingPath(INDEX_FILE_PATH));
}
}
代码示例来源:origin: real-logic/artio
MonitoringFile(final boolean newFile, final CommonConfiguration configuration)
{
final File file = new File(configuration.monitoringFile()).getAbsoluteFile();
absolutePath = file.getAbsolutePath();
CloseChecker.validate(absolutePath);
CloseChecker.onOpen(absolutePath, this);
final int length;
if (newFile)
{
IoUtil.deleteIfExists(file);
length = configuration.monitoringBuffersLength();
mappedByteBuffer = LoggerUtil.mapNewFile(file, length);
}
else
{
if (!file.exists() || !file.canRead() || !file.isFile())
{
throw new IllegalStateException("Unable to read from file: " + file);
}
mappedByteBuffer = IoUtil.mapExistingFile(file, "counters file");
length = mappedByteBuffer.capacity();
}
final AtomicBuffer mappedFile = new UnsafeBuffer(mappedByteBuffer);
errorBuffer = new UnsafeBuffer(mappedFile, 0, length);
}
代码示例来源:origin: real-logic/artio
@Test
public void copiesOldSessionContextFile() throws IOException
{
final File backupLocation = File.createTempFile("sessionContexts", "tmp");
try
{
final SessionContext aContext = sessionContexts.onLogon(aSession);
sessionContexts.onDisconnect(aContext.sessionId());
final byte[] oldData = new byte[BUFFER_SIZE];
buffer.getBytes(0, oldData);
sessionContexts.reset(backupLocation);
verify(mappedFile).transferTo(backupLocation);
}
finally
{
IoUtil.deleteIfExists(backupLocation);
}
}
代码示例来源:origin: real-logic/artio
@Before
public void setUp()
{
mediaDriver = TestFixtures.launchMediaDriver();
aeronArchive = AeronArchive.connect();
recordingIdLookup = new RecordingIdLookup(new YieldingIdleStrategy(), aeron().countersReader());
aeronArchive.startRecording(CHANNEL, STREAM_ID, SourceLocation.LOCAL);
final Aeron aeron = aeron();
publication = aeron.addExclusivePublication(CHANNEL, STREAM_ID);
subscription = aeron.addSubscription(CHANNEL, STREAM_ID);
final File logFile = logFile(SESSION_ID);
IoUtil.deleteIfExists(logFile);
newReplayIndex();
query = new ReplayQuery(
DEFAULT_LOG_FILE_DIR,
DEFAULT_LOGGER_CACHE_NUM_SETS,
DEFAULT_LOGGER_CACHE_SET_SIZE,
existingBufferFactory,
DEFAULT_OUTBOUND_LIBRARY_STREAM,
new NoOpIdleStrategy(),
aeronArchive,
errorHandler,
DEFAULT_ARCHIVE_REPLAY_STREAM);
returnBuffer(indexBuffer, SESSION_ID);
returnBuffer(ByteBuffer.allocate(16 * 1024), SESSION_ID_2);
when(newBufferFactory.map(any(), anyInt())).thenReturn(indexBuffer);
}
内容来源于网络,如有侵权,请联系作者删除!