本文整理了Java中org.geoserver.util.IOUtils
类的一些代码示例,展示了IOUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils
类的具体详情如下:
包路径:org.geoserver.util.IOUtils
类名称:IOUtils
[英]Utility class for IO related utilities
[中]与IO相关的实用程序的实用程序类
代码示例来源:origin: geoserver/geoserver
/**
* Copies the provided input stream onto a file
*
* @param from
* @param to
* @throws IOException
*/
public static void copy(InputStream from, File to) throws IOException {
copy(from, new FileOutputStream(to));
}
代码示例来源:origin: geoserver/geoserver
public void setUpSecurity() throws IOException {
File secDir = new File(getDataDirectoryRoot(), "security");
IOUtils.decompress(SystemTestData.class.getResourceAsStream("security.zip"), secDir);
String javaVendor = System.getProperty("java.vendor");
if (javaVendor.contains("IBM")) {
IOUtils.copy(
new File(secDir, "geoserver.jceks.ibm"), new File(secDir, "geoserver.jceks"));
} else {
IOUtils.copy(
new File(secDir, "geoserver.jceks.default"),
new File(secDir, "geoserver.jceks"));
}
}
代码示例来源:origin: geoserver/geoserver
public void tearDown() throws Exception {
if (data != null) {
IOUtils.delete(data);
}
}
}
代码示例来源:origin: geoserver/geoserver
@Override
public void setUp() throws Exception {
data = IOUtils.createRandomDirectory("./target", "live", "data");
IOUtils.deepCopy(source, data);
}
代码示例来源:origin: geoserver/geoserver
/**
* Copy the contents of fromDir into toDir (if the latter is missing it will be created)
*
* @param fromDir
* @param toDir
* @throws IOException
*/
public static void deepCopy(File fromDir, File toDir) throws IOException {
if (!fromDir.isDirectory() || !fromDir.exists())
throw new IllegalArgumentException(
"Invalid source directory "
+ "(it's either not a directory, or does not exist");
if (toDir.exists() && toDir.isFile())
throw new IllegalArgumentException(
"Invalid destination directory, " + "it happens to be a file instead");
// create destination if not available
if (!toDir.exists()) if (!toDir.mkdir()) throw new IOException("Could not create " + toDir);
File[] files = fromDir.listFiles();
for (File file : files) {
File destination = new File(toDir, file.getName());
if (file.isDirectory()) deepCopy(file, destination);
else copy(file, destination);
}
}
代码示例来源:origin: geoserver/geoserver
public MockData() throws IOException {
data = IOUtils.createRandomDirectory("./target", "mock", "data");
data.delete();
data.mkdir();
styles.mkdir();
IOUtils.copy(
MockData.class.getResourceAsStream("Default.sld"), new File(styles, "Default.sld"));
代码示例来源:origin: geoserver/geoserver
/**
* Unzips a SLD package to a temporal folder, returning the SLD file path.
*
* @param input
* @throws IOException
*/
private File unzipSldPackage(Object input) throws IOException {
File myTempDir = Files.createTempDir();
org.geoserver.util.IOUtils.decompress((InputStream) input, myTempDir);
File[] files =
myTempDir.listFiles(
new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".sld");
}
});
if (files.length != 1) {
throw new IOException("No SLD file");
}
return files[0];
}
}
代码示例来源:origin: org.geoserver.extension/gs-h2
/** Helper method that zips the H2 data directory and returns it as an array of bytes. */
private static byte[] readSqLiteDatabaseDir() throws Exception {
// copy database file to database directory
File outputFile = new File(DATABASE_DIR, "test-database.data.db");
InputStream input = RestTest.class.getResourceAsStream("/test-database.data.db");
IOUtils.copy(input, new FileOutputStream(outputFile));
// zip the database directory
ByteArrayOutputStream output = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(output);
// ignore the lock files
IOUtils.zipDirectory(
DATABASE_DIR, zip, (dir, name) -> !name.toLowerCase().contains("lock"));
zip.close();
// just return the output stream content
return output.toByteArray();
}
}
代码示例来源:origin: org.geoserver/gs-restconfig
String path;
try {
path = IOUtils.toString(request.getInputStream());
} catch (IOException e) {
throw new RestException(
IOUtils.copy(source.in(), resource.out());
} catch (IOException e) {
throw new RestException(
IOUtils.copy(request.getInputStream(), resource.out());
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.fine("PUT resource: " + resource.path());
代码示例来源:origin: geoserver/geoserver
@Test
public void testZipUnzip() throws IOException {
Path p1 = temp.newFolder("d1").toPath();
p1.resolve("foo/bar").toFile().mkdirs();
Files.touch(p1.resolve("foo/bar/bar.txt").toFile());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ZipOutputStream zout = new ZipOutputStream(bout);
IOUtils.zipDirectory(p1.toFile(), zout, null);
Path p2 = temp.newFolder("d2").toPath();
p2.toFile().mkdirs();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
IOUtils.decompress(bin, p2.toFile());
assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists());
}
代码示例来源:origin: org.geoserver/gs-wfs
final File tempDir = IOUtils.createTempDirectory("shpziptemp");
ShapefileDumper dumper =
new ShapefileDumper(tempDir) {
IOUtils.zipDirectory(tempDir, zipOut, filter);
zipOut.finish();
代码示例来源:origin: org.geoserver.extension/gs-wps-core
@Override
public Object decode(InputStream input) throws Exception {
File tempDir = IOUtils.createTempDirectory("shpziptemp");
File file = IOUtils.getZipOutputFile(tempDir, entry);
if (entry.isDirectory()) {
file.mkdir();
代码示例来源:origin: geoserver/geoserver
/**
* Zips up the directory contents into the specified {@link ZipOutputStream}.
*
* <p>Note this method does not take ownership of the provided zip output stream, meaning the
* client code is responsible for calling {@link ZipOutputStream#finish() finish()} when it's
* done adding zip entries.
*
* @param directory The directory whose contents have to be zipped up
* @param zipout The {@link ZipOutputStream} that will be populated by the files found
* @param filter An optional filter that can be used to select only certain files. Can be null,
* in that case all files in the directory will be zipped
* @throws IOException
* @throws FileNotFoundException
*/
public static void zipDirectory(
File directory, ZipOutputStream zipout, final FilenameFilter filter)
throws IOException, FileNotFoundException {
zipDirectory(directory, "", zipout, filter);
}
代码示例来源:origin: org.geoserver.community/gs-jms-geoserver
/** Helper method that just creates a temporary directory using the provide prefix. */
private static File createTempDirectory(String prefix) {
try {
// creates a temporary directory using the provided prefix
return IOUtils.createTempDirectory(prefix + "-");
} catch (Exception exception) {
throw new RuntimeException("Error creating temporary directory.", exception);
}
}
代码示例来源:origin: org.geoserver.community/gs-jms-geoserver
public GeoServerInstance(String instanceName) {
try {
// create this instance base data directory by copying the base test data
dataDirectory = createTempDirectory(instanceName == null ? "INSTANCE" : instanceName);
IOUtils.deepCopy(BASE_TEST_DATA.getDataDirectoryRoot(), dataDirectory);
// disable security manager to speed up tests
System.setSecurityManager(null);
// take control of the logging
Logging.ALL.setLoggerFactory(Log4JLoggerFactory.getInstance());
System.setProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, "true");
// initialize Spring application context
applicationContext = initInstance();
// get some JMS util beans
jmsController = applicationContext.getBean(Controller.class);
jmsQueueListener = applicationContext.getBean(JMSQueueListener.class);
// set integration tests cluster name
jmsController.setGroup(CLUSTER_NAME);
saveJmsConfiguration();
} catch (Exception exception) {
throw new RuntimeException(
String.format("Error instantiating GeoServer instance '%s'.", instanceName),
exception);
}
}
代码示例来源:origin: geoserver/geoserver
@Override
public void setUpSecurity() throws IOException {
File secDir = new File(getDataDirectoryRoot(), "security");
IOUtils.decompress(
Security_2_2_TestData.class.getResourceAsStream("security-2.2.zip"), secDir);
}
}
代码示例来源:origin: org.geoserver/gs-platform
@Test
public void testZipUnzip() throws IOException {
Path p1 = temp.newFolder("d1").toPath();
p1.resolve("foo/bar").toFile().mkdirs();
Files.touch(p1.resolve("foo/bar/bar.txt").toFile());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ZipOutputStream zout = new ZipOutputStream(bout);
IOUtils.zipDirectory(p1.toFile(), zout, null);
Path p2 = temp.newFolder("d2").toPath();
p2.toFile().mkdirs();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
IOUtils.decompress(bin, p2.toFile());
assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists());
}
代码示例来源:origin: geoserver/geoserver
/**
* Deeps copy the dataDirSourceDirectory provided in the constructor into a temporary directory.
* Subclasses may override it in order to add extra behavior (like setting up an external
* database)
*/
public void setUp() throws Exception {
data = IOUtils.createRandomDirectory("./target", "live", "data");
IOUtils.deepCopy(source, data);
}
代码示例来源:origin: geoserver/geoserver
zipDirectory(file, newPrefix, zipout, filter);
} else {
ZipEntry entry = new ZipEntry(prefix + file.getName());
代码示例来源:origin: org.geoserver.extension/gs-h2
@BeforeClass
public static void setUp() throws Throwable {
// create root tests directory
ROOT_DIRECTORY = IOUtils.createTempDirectory("h2-tests");
// create the test database
DATABASE_DIR = new File(ROOT_DIRECTORY, "testdb");
DATABASE_DIR.mkdirs();
}
内容来源于网络,如有侵权,请联系作者删除!