use of java.io.UncheckedIOException in project gatk-protected by broadinstitute.
the class XHMMSegmentCallerBaseIntegrationTest method writeChainInTempFile.
public static File writeChainInTempFile(final XHMMData chain) {
final File result = createTempFile("chain-", ".tab");
//final File result = new File("/tmp/input");
final List<String> sampleNames = IntStream.range(0, chain.data.size()).mapToObj(a -> "SAMPLE_" + a).collect(Collectors.toList());
final List<String> columnNames = new ArrayList<>(sampleNames.size() + 4);
columnNames.addAll(Arrays.asList(TargetTableColumn.CONTIG.toString(), TargetTableColumn.START.toString(), TargetTableColumn.END.toString(), TargetTableColumn.NAME.toString()));
columnNames.addAll(sampleNames);
try (final TableWriter<Integer> writer = new TableWriter<Integer>(result, new TableColumnCollection(columnNames)) {
@Override
protected void composeLine(final Integer record, final DataLine dataLine) {
dataLine.append(chain.targets.get(record).getContig()).append(chain.targets.get(record).getStart()).append(chain.targets.get(record).getEnd()).append(chain.targets.get(record).getName());
for (final List<Double> sampleData : chain.data) {
dataLine.append(sampleData.get(record));
}
}
}) {
writer.writeAllRecords(IntStream.range(0, chain.targets.size()).boxed().collect(Collectors.toList()));
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
return result;
}
use of java.io.UncheckedIOException in project gatk by broadinstitute.
the class XHMMSegmentCallerBaseIntegrationTest method writeChainInTempFile.
public static File writeChainInTempFile(final XHMMData chain) {
final File result = createTempFile("chain-", ".tab");
//final File result = new File("/tmp/input");
final List<String> sampleNames = IntStream.range(0, chain.data.size()).mapToObj(a -> "SAMPLE_" + a).collect(Collectors.toList());
final List<String> columnNames = new ArrayList<>(sampleNames.size() + 4);
columnNames.addAll(Arrays.asList(TargetTableColumn.CONTIG.toString(), TargetTableColumn.START.toString(), TargetTableColumn.END.toString(), TargetTableColumn.NAME.toString()));
columnNames.addAll(sampleNames);
try (final TableWriter<Integer> writer = new TableWriter<Integer>(result, new TableColumnCollection(columnNames)) {
@Override
protected void composeLine(final Integer record, final DataLine dataLine) {
dataLine.append(chain.targets.get(record).getContig()).append(chain.targets.get(record).getStart()).append(chain.targets.get(record).getEnd()).append(chain.targets.get(record).getName());
for (final List<Double> sampleData : chain.data) {
dataLine.append(sampleData.get(record));
}
}
}) {
writer.writeAllRecords(IntStream.range(0, chain.targets.size()).boxed().collect(Collectors.toList()));
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
return result;
}
use of java.io.UncheckedIOException in project jgnash by ccavanaugh.
the class FXMLUtils method load.
/**
* Creates a new Stage with application defaults {@code StageStyle.DECORATED}, {@code Modality.APPLICATION_MODAL}
* with the specified fxml {@code URL} as the {@code Scene}. The default resource bundle is used.
*
* @param fxmlUrl the fxml {@code URL}
* @param title the Stage title
* @param <C> the fxml controller type
* @return Pair containing the Stage and controller
*/
public static <C> Pair<C> load(@NotNull final URL fxmlUrl, final String title) {
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlUrl, ResourceUtils.getBundle());
final Stage stage = new Stage(StageStyle.DECORATED);
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(MainView.getPrimaryStage());
try {
final Scene scene = new Scene(fxmlLoader.load());
scene.getStylesheets().addAll(MainView.DEFAULT_CSS);
scene.getRoot().styleProperty().bind(ThemeManager.styleProperty());
final C controller = fxmlLoader.getController();
stage.setScene(scene);
stage.getIcons().add(StaticUIMethods.getApplicationIcon());
stage.setTitle(title);
// force a resize, some stages need a push
stage.sizeToScene();
// Inject the scene into the controller
injectParent(controller, scene);
stage.setOnShown(event -> Platform.runLater(() -> {
stage.sizeToScene();
stage.setMinHeight(stage.getHeight());
stage.setMinWidth(stage.getWidth());
}));
return new Pair<>(controller, stage);
} catch (final IOException ioe) {
// log and throw an unchecked exception
Logger.getLogger(FXMLUtils.class.getName()).log(Level.SEVERE, ioe.getMessage(), ioe);
throw new UncheckedIOException(ioe);
}
}
use of java.io.UncheckedIOException in project chuidiang-ejemplos by chuidiang.
the class WriteFile method writeWithFilesAndStream.
private static void writeWithFilesAndStream() {
String[] lines = new String[] { "line 1", "line 2", "line 2" };
Path path = Paths.get("outputfile.txt");
try (BufferedWriter br = Files.newBufferedWriter(path, Charset.defaultCharset(), StandardOpenOption.CREATE)) {
Arrays.stream(lines).forEach((s) -> {
try {
br.write(s);
br.newLine();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
use of java.io.UncheckedIOException in project ddf by codice.
the class IngestCommand method buildQueue.
private void buildQueue(File inputFile, ArrayBlockingQueue<Metacard> metacardQueue, long start) {
try {
if (includeContent) {
processIncludeContent(metacardQueue);
} else {
try {
Stream<Path> ingestStream = Files.walk(inputFile.toPath(), FileVisitOption.FOLLOW_LINKS);
ingestStream.map(Path::toFile).filter(file -> !file.isDirectory()).forEach(file -> addFileToQueue(metacardQueue, start, file));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
} finally {
phaser.arriveAndDeregister();
}
}
Aggregations