@Override public InMemoryResource parsePath(final String path) { return new InMemoryResource(path); }
@Override public OutputStream append() throws ResourceException { return createOutputStream(true); }
@Override public String createPath(final Resource res) { final InMemoryResource resource = (InMemoryResource) res; return resource.getPath(); }
@Override public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException { assert accepts(properties); return new InMemoryResource(properties.getUri().getPath()); } }
@Override public OutputStream append() throws ResourceException { return createOutputStream(true); }
@Override public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException { assert accepts(properties); return new InMemoryResource(properties.getUri().getPath()); } }
@Override public OutputStream write() throws ResourceException { return createOutputStream(false); }
/** * Writes the {@link Workbook} to a {@link Resource}. The {@link Workbook} will be closed as a result of this * operation! * * @param dataContext * @param wb */ public static void writeAndCloseWorkbook(ExcelDataContext dataContext, final Workbook wb) { // first write to a temp file to avoid that workbook source is the same // as the target (will cause read+write cyclic overflow) final Resource realResource = dataContext.getResource(); final Resource tempResource = new InMemoryResource(realResource.getQualifiedPath()); tempResource.write(out -> wb.write(out)); FileHelper.safeClose(wb); FileHelper.copy(tempResource, realResource); }
@Override public OutputStream write() throws ResourceException { return createOutputStream(false); }
/** * Writes the {@link Workbook} to a {@link Resource}. The {@link Workbook} will be closed as a result of this * operation! * * @param dataContext * @param wb */ public static void writeAndCloseWorkbook(ExcelDataContext dataContext, final Workbook wb) { // first write to a temp file to avoid that workbook source is the same // as the target (will cause read+write cyclic overflow) final Resource realResource = dataContext.getResource(); final Resource tempResource = new InMemoryResource(realResource.getQualifiedPath()); tempResource.write(out -> wb.write(out)); FileHelper.safeClose(wb); FileHelper.copy(tempResource, realResource); }
try { final CsvDataContext testDataContext = new CsvDataContext(new InMemoryResource("foo.txt", sample, System.currentTimeMillis()), multiLineConfiguration); final Table table = testDataContext.getDefaultSchema().getTable(0);