本文整理汇总了Java中org.apache.commons.io.output.ByteArrayOutputStream.flush方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayOutputStream.flush方法的具体用法?Java ByteArrayOutputStream.flush怎么用?Java ByteArrayOutputStream.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.output.ByteArrayOutputStream
的用法示例。
在下文中一共展示了ByteArrayOutputStream.flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentScreen
import org.apache.commons.io.output.ByteArrayOutputStream; //导入方法依赖的package包/类
public Pair<ProcessingLifecycleStatus, byte[]> getCurrentScreen(final ProcessingLifecycleStatus status, final AssumedScreenTest screenTest) throws ApplicationDownException, IOException {
if(!processManager.isMtgoRunningOrLoading()) {
throw new ApplicationDownException("MTGO is not running!");
}
BufferedImage bi = robot.createScreenCapture(new Rectangle(0, 0, screenWidth, screenHeight));
if(bi != null) {
RawLines rawLines;
if (screenTest == AssumedScreenTest.NOT_NEEDED) {
rawLines = tesseractWrapper.getRawText(bi);
} else {
rawLines = tesseractWrapper.getRawText(bi, screenTest.getScreenTestBounds());
}
logger.info("Processing raw lines");
final ProcessingLifecycleStatus outcomeStatus = rawLinesProcessor.determineLifecycleStatus(rawLines);
logger.info("Determined new status: " + status.name());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
baos.flush();
byte[] imageAsByteArray = baos.toByteArray();
baos.close();
return new ImmutablePair<>(outcomeStatus, imageAsByteArray);
}
throw new ApplicationDownException("Somehow made it to this unreachable point");
}
示例2: createBotCamera
import org.apache.commons.io.output.ByteArrayOutputStream; //导入方法依赖的package包/类
private BotCamera createBotCamera(BufferedImage image, PlayerBot remotePlayerBot) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos );
baos.flush();
byte[] imageInByte = baos.toByteArray();
BotCamera botCamera = new BotCamera(imageInByte, new Date());
botCamera.setPlayerBot(remotePlayerBot);
return botCamera;
}
示例3: writeNiFiPropertiesFile
import org.apache.commons.io.output.ByteArrayOutputStream; //导入方法依赖的package包/类
protected static void writeNiFiPropertiesFile(ByteArrayOutputStream nifiPropertiesOutputStream, String destPath) throws IOException {
final Path nifiPropertiesPath = Paths.get(destPath, "nifi.properties");
try (FileOutputStream nifiProperties = new FileOutputStream(nifiPropertiesPath.toString())) {
nifiPropertiesOutputStream.writeTo(nifiProperties);
} finally {
if (nifiPropertiesOutputStream != null) {
nifiPropertiesOutputStream.flush();
nifiPropertiesOutputStream.close();
}
}
}