当前位置: 首页>>代码示例>>Java>>正文


Java IOUtil类代码示例

本文整理汇总了Java中org.databene.commons.IOUtil的典型用法代码示例。如果您正苦于以下问题:Java IOUtil类的具体用法?Java IOUtil怎么用?Java IOUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IOUtil类属于org.databene.commons包,在下文中一共展示了IOUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import org.databene.commons.IOUtil; //导入依赖的package包/类
@Override
public DataContainer<ResultSet> next(DataContainer<ResultSet> container) {
       LOGGER.debug("next() called on {}", this);
       if (resultSet == null)
       	return null;
	try {
		if (resultSet.next()) {
			return container.setData(resultSet);
		} else {
			IOUtil.close(this);
			return null;
		}
	} catch (SQLException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:17,代码来源:ResultSetDataIterator.java

示例2: exportColumns

import org.databene.commons.IOUtil; //导入依赖的package包/类
private void exportColumns(Database database) throws IOException {
	File file = new File(rootDirectory, "colums.csv");
	PrintWriter out = null;
	try {
		out = createPrintWriter(file);
		out.print(CSVUtil.formatHeaderWithLineFeed(',', "catalog", "schema", "table", "column_name", 
				"type", "jdbc_type", "nullable", "defaultValue"));
		for (DBTable table : database.getTables()) {
			for (DBColumn column : table.getColumns()) {
				CSVUtil.writeRow(out, ',', 
					table.getCatalog().getName(),
					table.getSchema().getName(),
					table.getName(),
					column.getName(),
					SQLUtil.renderColumnTypeWithSize(column),
					String.valueOf(column.getType().getJdbcType()),
					String.valueOf(column.isNullable()),
					column.getDefaultValue());
			}
		}
	} finally {
		IOUtil.close(out);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:25,代码来源:CSVModelExporter.java

示例3: exportPrimaryKeys

import org.databene.commons.IOUtil; //导入依赖的package包/类
private void exportPrimaryKeys(Database database) throws IOException {
	File file = new File(rootDirectory, "primary_keys.csv");
	PrintWriter out = null;
	try {
		out = createPrintWriter(file);
		out.print(CSVUtil.formatHeaderWithLineFeed(',', "catalog", "schema", "table", "pk_name", "column_name"));
		for (DBTable table : database.getTables()) {
			DBPrimaryKeyConstraint pk = table.getPrimaryKeyConstraint();
			if (pk == null)
				continue;
			for (String columnName : pk.getColumnNames()) {
				CSVUtil.writeRow(out, ',', 
					table.getCatalog().getName(),
					table.getSchema().getName(),
					table.getName(),
					pk.getName(),
					columnName);
			}
		}
	} finally {
		IOUtil.close(out);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:24,代码来源:CSVModelExporter.java

示例4: exportUniqueKeys

import org.databene.commons.IOUtil; //导入依赖的package包/类
private void exportUniqueKeys(Database database) throws IOException {
	File file = new File(rootDirectory, "unique_keys.csv");
	PrintWriter out = null;
	try {
		out = createPrintWriter(file);
		out.print(CSVUtil.formatHeaderWithLineFeed(',', "catalog", "schema", "table", "uk_name", "column_name"));
		for (DBTable table : database.getTables()) {
			for (DBUniqueConstraint uk : table.getUniqueConstraints(false)) {
				for (String columnName : uk.getColumnNames()) {
					CSVUtil.writeRow(out, ',', 
						table.getCatalog().getName(),
						table.getSchema().getName(),
						table.getName(),
						uk.getName(),
						columnName);
				}
			}
		}
	} finally {
		IOUtil.close(out);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:23,代码来源:CSVModelExporter.java

示例5: exportChecks

import org.databene.commons.IOUtil; //导入依赖的package包/类
private void exportChecks(Database database) throws IOException {
	File file = new File(rootDirectory, "checks.csv");
	PrintWriter out = null;
	try {
		out = createPrintWriter(file);
		out.print(CSVUtil.formatHeaderWithLineFeed(',', "catalog", "schema", "table", "check"));
		for (DBTable table : database.getTables()) {
			for (DBCheckConstraint check : table.getCheckConstraints()) {
				CSVUtil.writeRow(out, ',', 
					table.getCatalog().getName(),
					table.getSchema().getName(),
					table.getName(),
					check.getName(),
					SQLUtil.normalize(check.getConditionText(), true));
			}
		}
	} finally {
		IOUtil.close(out);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:21,代码来源:CSVModelExporter.java

示例6: exportIndexes

import org.databene.commons.IOUtil; //导入依赖的package包/类
private void exportIndexes(Database database) throws IOException {
	File file = new File(rootDirectory, "indexes.csv");
	PrintWriter out = null;
	try {
		out = createPrintWriter(file);
		out.print(CSVUtil.formatHeaderWithLineFeed(',', 
				"catalog", "schema", "table", "index_name", "index_unique", "column_name"));
		for (DBTable table : database.getTables()) {
			for (DBIndex index : table.getIndexes()) {
				for (String columnName : index.getColumnNames()) {
					CSVUtil.writeRow(out, ',', 
						table.getCatalog().getName(),
						table.getSchema().getName(),
						table.getName(),
						index.getName(),
						String.valueOf(index.isUnique()),
						columnName);
				}
			}
		}
	} finally {
		IOUtil.close(out);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:25,代码来源:CSVModelExporter.java

示例7: environmentFileName

import org.databene.commons.IOUtil; //导入依赖的package包/类
public static String environmentFileName(String environment) throws IOException {
	String filename = environment + ".env.properties";
	File file = FileUtil.getFileIgnoreCase(new File(filename), false);
	if (!file.exists()) {
		File defaultUserHomeFile = new File(SystemInfo.getUserHome() + SystemInfo.getFileSeparator() + "databene", filename);
		file = FileUtil.getFileIgnoreCase(defaultUserHomeFile, false);
	}
	String path;
	if (file.exists()) {
		path = file.getCanonicalPath();
	} else if (IOUtil.isURIAvailable(filename)) {
		path = filename;
	} else {
		throw new ConfigurationError("No environment definition '" + filename + "' found");
	}
	return path;
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:18,代码来源:DBUtil.java

示例8: testOnline

import org.databene.commons.IOUtil; //导入依赖的package包/类
@Test
public void testOnline() throws Exception {
	XMLModelImporter importer = new XMLModelImporter(LAZY_TEST_MODEL_FILENAME, new JDBCDBImporter(ENVIRONMENT));
	try {
		Database db = importer.importDatabase();
		new TreeLogger().log(new DBTreeModel(db));
		assertFalse(db.isSequencesImported());
		List<DBSequence> sequences = db.getSequences();
		assertEquals(1, sequences.size());
		assertEquals("SEQ1", sequences.get(0).getName());
		assertEquals(BigInteger.valueOf(1000), sequences.get(0).getStart());
		assertTrue(db.isSequencesImported());
	} finally {
		IOUtil.close(importer);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:17,代码来源:XMLModelImporterTest.java

示例9: persistWoorkbook

import org.databene.commons.IOUtil; //导入依赖的package包/类
boolean persistWoorkbook() throws IOException {
    File targetFolder = this.file.getCanonicalFile().getParentFile();
    if (!targetFolder.exists()) {
        if (!targetFolder.mkdirs()) {
            throw new IOException("Unable to create directory " + targetFolder.getAbsolutePath());
        }
    }
    OutputStream out = null;
    try {
        out = new FileOutputStream(this.file);
        this.workbook.write(out);
    }
    finally {
        IOUtil.close(out);
    }
    return true;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:18,代码来源:WorkbookTracker.java

示例10: createDocument

import org.databene.commons.IOUtil; //导入依赖的package包/类
@Override
public Document createDocument(String templateUri, String templateEncoding, Map<String, Object> variables) {
    try {
        // prepare generator
        FreeMarkerScriptFactory factory = new FreeMarkerScriptFactory(Locale.ENGLISH);
        String templateText = IOUtil.getContentOfURI(templateUri, templateEncoding);
        Script script = factory.parseText(templateText);
        Context context = new DefaultContext(variables);
        // apply template
        String xmlText = String.valueOf(script.evaluate(context));
        // return result
        return XMLUtil.parseString(xmlText);
    }
    catch (IOException e) {
        throw new TechnicalException("Error creating XML document", e);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:18,代码来源:XmlContentImpl.java

示例11: verifyWith

import org.databene.commons.IOUtil; //导入依赖的package包/类
/** Asserts that the interchange stored in this document is equals to the provided interchange, ignoring the provided paths.
 * @param referenceFileUri the URI of the reference file to verify against
 * @return a reference to the invoked EdifactFileVerifier instance */
public E verifyWith(StringData referenceFileUri) {
    InputStream referenceFileStream = null;
    try {
        referenceFileStream = IOUtil.getInputStreamForURI(referenceFileUri.getValue());
    }
    catch (IOException e) {
        IOUtil.close(referenceFileStream);
        throw new AutomationException("Failed to read reference file", e);
    }
    Interchange expected = service.perform().readInterchange(elementType, "reference file", referenceFileStream);
    Interchange actual = service.perform().readInterchange(
            elementType, "outbound file", this.filePath);
    service.verify().assertInterchangesMatch(elementType, null, expected, actual, settings);
    return (E) this;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:19,代码来源:EdifactFileVerifier.java

示例12: writeBinaryFile

import org.databene.commons.IOUtil; //导入依赖的package包/类
/** Creates a binary file and writes to it all content provided by the source {@link InputStream}.
 * @param filePath the path of the file to save
 * @param source an {@link InputStream} which provides the content to write to the file
 * @param overwrite flag which indicates if an existing file may be overwritten by the operation
 * @return true if a formerly existing file was overwritten.
 * @throws FunctionalFailure if a file was already present and overwriting was disabled. */
@Override
public boolean writeBinaryFile(String filePath, InputStream source, boolean overwrite) {
    assertWritingPermitted("writeBinaryFile()");
    File.verifyFilePath(filePath);
    OutputStream out = null;
    try {
        FileObject target = getFileObject(filePath);
        boolean existedBefore = checkWritable(target, overwrite); // NOSONAR
        out = target.getContent().getOutputStream();
        IOUtil.transfer(source, out);
        logger.debug("Wrote binary file {}", filePath);
        return existedBefore;
    }
    catch (IOException e) {
        throw new TechnicalException("Error writing text file", e);
    }
    finally {
        IOUtil.close(out);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:27,代码来源:FileInteractionImpl.java

示例13: readBinaryFile

import org.databene.commons.IOUtil; //导入依赖的package包/类
/** Reads a binary file and provides its content as an array of bytes. */
@Override
public byte[] readBinaryFile(String filePath) {
    File.verifyFilePath(filePath);
    if (!exists(filePath) || isDirectory(filePath)) {
        throw new AutomationException("No file exists at the given file path");
    }

    InputStream in = null;
    try {
        in = getInputStreamForFile(filePath);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        IOUtil.transfer(in, out);
        logger.debug("Binary file read: {}", filePath);
        return out.toByteArray();
    }
    catch (IOException e) {
        throw new TechnicalException("Error reading binary file", e);
    }
    finally {
        IOUtil.close(in);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:24,代码来源:FileInteractionImpl.java

示例14: redirectTo

import org.databene.commons.IOUtil; //导入依赖的package包/类
public void redirectTo(OutputStream out) throws IOException {
    if (!bufferedTextAvailable()) {
        if (process.isRunning()) {
            // expect process output
            waitUntilAvailable();
        }
        else if (!availableWithinResponseTimeout()) {
            // perform another check if process output was pending
            // (necessary for Windows)
            return;
        }
    }
    InputStream bufferStream;
    synchronized (buffer) {
        bufferStream = new ByteArrayInputStream(this.buffer.getBytes(), this.pos, this.buffer.length() - this.pos);
    }
    IOUtil.transfer(bufferStream, out);
    out.flush();
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:20,代码来源:InputStreamWatchDog.java

示例15: test

import org.databene.commons.IOUtil; //导入依赖的package包/类
@Test
public void test() throws Exception {
    String filePath = "target/sepfwtest.csv";
    FileWriter out = null;
    try {
        out = new FileWriter(filePath);
        SeparatedFileWriter writer = new SeparatedFileWriter(out, SepPersonData.class, '\t', "VER1234");
        writer.writeRow(new SepPersonData("Alice", "23"));
        writer.writeRow(new SepPersonData("Bob", "34"));
        IOUtil.close(writer);
    } finally {
        IOUtil.close(out);
    }
    ReaderLineIterator iterator = new ReaderLineIterator(new FileReader(filePath));
    assertTrue(iterator.hasNext());
    assertEquals("VER1234", iterator.next());
    assertTrue(iterator.hasNext());
    assertEquals("Alice\t23", iterator.next());
    assertTrue(iterator.hasNext());
    assertEquals("Bob\t34", iterator.next());
    assertFalse(iterator.hasNext());
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:23,代码来源:SeparatedFileWriterTest.java


注:本文中的org.databene.commons.IOUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。