本文整理汇总了Java中java.io.File.mkdir方法的典型用法代码示例。如果您正苦于以下问题:Java File.mkdir方法的具体用法?Java File.mkdir怎么用?Java File.mkdir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFileSystem
import java.io.File; //导入方法依赖的package包/类
public boolean checkFileSystem() {
// CHEQUEAMOS Y CREAMOS LAS CARPETAS
this.log.Info("Verificando sistema de archivos");
File geos = new File("kernel");
File logs = new File("kernel/logs");
File properties = new File("kernel/properties");
File backups = new File("kernel/backups");
File model = new File("kernel/model");
File controller = new File("kernel/controller");
File policies = new File("kernel/policies");
//CHEQUEAMOS
boolean status = true;
if(!geos.exists()) status = geos.mkdir();
if(status && !logs.exists()) status = logs.mkdir();
if(status && !properties.exists()) status = properties.mkdir();
if(status && !backups.exists()) status = backups.mkdir();
if(status && !model.exists()) status = model.mkdir();
if(status && !controller.exists()) status = controller.mkdir();
if(status && !policies.exists()) status = policies.mkdir();
return status;
}
示例2: setUp
import java.io.File; //导入方法依赖的package包/类
@Before
public void setUp() {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty(LOG_LEVEL, "config"); // to keep diskPerf logs smaller
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
props.setProperty(ENABLE_TIME_STATISTICS, "true");
props.setProperty(STATISTIC_ARCHIVE_FILE, "stats.gfs");
ds = DistributedSystem.connect(props);
cache = CacheFactory.create(ds);
File diskStore = new File("diskStore");
diskStore.mkdir();
cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(new File[] {diskStore})
.create("store");
region = cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT)
.setDiskStoreName("store").create("region");
ex = Executors.newSingleThreadExecutor();
}
示例3: getDeviceId
import java.io.File; //导入方法依赖的package包/类
public static String getDeviceId(Context context) {
String androidId = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ANDROID_ID);
if (!TextUtils.isEmpty(androidId)) {
String serial = Build.SERIAL;
if (!"unknown".equalsIgnoreCase(serial)) {
return androidId + serial;
}
return androidId;
}
File file = new File(context.getFilesDir(), "deviceId");
file.mkdir();
File[] files = file.listFiles();
if (files.length > 0) {
return files[0].getName();
}
String id = UUID.randomUUID().toString();
(new File(file, id)).mkdir();
return id;
}
示例4: getSDFileDir
import java.io.File; //导入方法依赖的package包/类
public File getSDFileDir() {
File sdDir = null;
boolean sdCardExist = Environment.getExternalStorageState()
.equals(android.os.Environment.MEDIA_MOUNTED); //判断sd卡是否存在
if (!sdCardExist) {
return null;
}
sdDir = Environment.getExternalStorageDirectory();//获取跟目录
File dir = new File(sdDir + File.separator + "WcsSdk");
if (!dir.exists()) {
dir.mkdir();
}
if (mFilePath == null) {
mFilePath = dir.toString();
}
return dir;
}
示例5: print
import java.io.File; //导入方法依赖的package包/类
@Override
public void print() {
File dir = new File(Constants.TYPE_PATH);
if (!dir.exists()) {
dir.mkdir();
}
File file = new File(Constants.TYPE_PATH, "sequences.txt");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
Arrays.stream(seqs).filter(Objects::nonNull).forEach((SequenceType t) -> {
TypePrinter.print(t, writer);
});
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: xmlConversionServiceFactoryForServlets
import java.io.File; //导入方法依赖的package包/类
/**
* Factory for use in Servlets to create an XMLConversionService using
* configurations found in the Servlet context parameters. This method also
* places the path to the XSL files directory in the servlet context under
* 'xslFilesDirecoryPath', for use by the JavaXmlConverters. <p>
*
* To configure a format converter that uses an XSL style sheet or Java class,
* the context param-name must begin with the either 'xslconverter' or
* 'javaconverter' and must be unique. The param-value must be of the form
* 'xslfile.xsl|[from format]\[to format]' or '[fully qualified Java
* class]|[from format]\[to format]'.
*
* @param servletContext The ServletContext
* @param xslFilesDirecory The base directory where the XSL files are
* located
* @param xmlCachDirecory The directory where the service will cache the
* converted XML files
* @param filterDeclarations Set to true to filter out the XML and DTD
* declarations in the converted XML
* @return The XMLConversionService
* @exception Exception If error
*/
public static XMLConversionService xmlConversionServiceFactoryForServlets(
ServletContext servletContext,
File xslFilesDirecory,
File xmlCachDirecory,
boolean filterDeclarations)
throws Exception {
// Set up an XML Conversion Service:
// Place the xsl dir path in the Servlet context for use by the JavaXmlConverters
servletContext.setAttribute("xslFilesDirecoryPath", xslFilesDirecory.getAbsolutePath());
XMLConversionService xmlConversionService = null;
xmlCachDirecory.mkdir();
xmlConversionService =
new XMLConversionService(xmlCachDirecory, filterDeclarations);
// Add configured converters:
Enumeration enumeration = servletContext.getInitParameterNames();
String param;
while (enumeration.hasMoreElements()) {
param = (String) enumeration.nextElement();
if (param.toLowerCase().startsWith("xslconverter")) {
xmlConversionService.addXslConverterHelper(servletContext.getInitParameter(param), xslFilesDirecory);
}
if (param.toLowerCase().startsWith("javaconverter")) {
xmlConversionService.addJavaConverterHelper(servletContext.getInitParameter(param), servletContext);
}
}
return xmlConversionService;
}
示例7: testIndexCreationFromXMLForLocalScope
import java.io.File; //导入方法依赖的package包/类
@Test
public void testIndexCreationFromXMLForLocalScope() throws Exception {
InternalDistributedSystem.getAnyInstance().disconnect();
File file = new File("persistData0");
file.mkdir();
Properties props = new Properties();
props.setProperty(NAME, "test");
props.setProperty(MCAST_PORT, "0");
props.setProperty(CACHE_XML_FILE,
getClass().getResource("index-creation-without-eviction.xml").toURI().getPath());
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
Region localRegion = cache.getRegion("localRegion");
for (int i = 0; i < 100; i++) {
Portfolio pf = new Portfolio(i);
localRegion.put("" + i, pf);
}
QueryService qs = cache.getQueryService();
Index ind = qs.getIndex(localRegion, "localIndex");
assertNotNull("Index localIndex should have been created ", ind);
// verify that a query on the creation time works as expected
SelectResults results = (SelectResults) qs
.newQuery("<trace>SELECT * FROM " + localRegion.getFullPath() + " Where ID > 0").execute();
assertEquals("OQL index results did not match", 99, results.size());
ds.disconnect();
FileUtil.delete(file);
}
示例8: createTempDirectory
import java.io.File; //导入方法依赖的package包/类
private static File createTempDirectory() throws IOException {
File tempDirectory = File.createTempFile("tinyb", "libs");
tempDirectory.delete();
tempDirectory.mkdir();
try {
tempDirectory.deleteOnExit();
} catch (Exception ignored) {
// old jvms
}
return tempDirectory;
}
示例9: createDirectory
import java.io.File; //导入方法依赖的package包/类
@Override
public DocumentFile createDirectory(String displayName) {
final File target = new File(mFile, displayName);
if (target.isDirectory() || target.mkdir()) {
return new RawDocumentFile(this, target);
} else {
return null;
}
}
示例10: load
import java.io.File; //导入方法依赖的package包/类
public static void load() {
File dir = NavyCraft.instance.getDataFolder();
if (!dir.exists())
dir.mkdir();
File config = new File(NavyCraft.instance.getDataFolder(), NavyCraft.instance.configFile.filename);
if (!config.exists()) {
return;
}
Document doc = null;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(config.toURI().getPath());
doc.getDocumentElement().normalize();
NodeList list;
for(Object configLine : NavyCraft.instance.configFile.ConfigSettings.keySet().toArray()) {
String configKey = (String) configLine;
list = doc.getElementsByTagName(configKey);
try {
String value = list.item(0).getChildNodes().item(0).getNodeValue();
NavyCraft.instance.configFile.ConfigSettings.put(configKey, value);
} catch (Exception ex){
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
示例11: setUpMyApp
import java.io.File; //导入方法依赖的package包/类
private void setUpMyApp() throws IOException, JSONException {
NodeVisitors visitor = new NodeVisitors(myApp);
EffectiveModel lamp = new EffectiveModel(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, log);
ArrayList<String> paths = new ArrayList<>();
String resourcesPath = "src/test/resources/";
File sourceDir = new File(resourcesPath + "csars/yaml/valid/lamp-noinput/");
targetDir = new File(tmpdir, "targetDir");
sourceDir.mkdir();
targetDir.mkdir();
PluginFileAccess fileAccess = new PluginFileAccess(sourceDir, targetDir, log);
Set<RootNode> nodes = lamp.getNodes();
paths.add("my_app/myphpapp.php");
paths.add("my_app/mysql-credentials.php");
paths.add("my_app/create_myphpapp.sh");
paths.add("my_app/configure_myphpapp.sh");
paths.add("my_db/createtable.sql");
for (VisitableNode node : nodes) {
node.accept(visitor);
}
myApp = visitor.getFilledApp();
assumeNotNull(connection);
myApp.setConnection(connection);
myApp.setProvider(provider);
String pathToApplication = myApp.getPathToApplication();
myApp.setPathToApplication(targetDir + "/" + pathToApplication + "/");
FileCreator fileCreator = new FileCreator(fileAccess, myApp);
fileCreator.createFiles();
}
示例12: report
import java.io.File; //导入方法依赖的package包/类
/**
* Report.
*
* @return true, if successful
*/
@Override
public boolean report() {
if (!registry.isEnabled()) {
return true;
}
File dir = new File(metricPath);
if (!dir.exists()) {
if (!dir.mkdir()) {
return false;
}
}
DateFormat formatter = new SimpleDateFormat(dateFormat);
String filename = metricPath + "/" + formatter.format(new Date(registry.getMillis())) + ".prom";
try {
FileOutputStream fos = new FileOutputStream(filename, true);
BufferedOutputStream out = new BufferedOutputStream(fos, 8192);
write(out);
out.close();
compress(filename);
remove(maxFileCount);
} catch (IOException e) {
// TODO: log
return false;
}
return true;
}
示例13: createFolderForLinkedFiles
import java.io.File; //导入方法依赖的package包/类
@Override
public String createFolderForLinkedFiles(String filename) throws Exception {
String bareFilename = getBareFilename(filename);
File newDir = new File(dir, bareFilename);
newDir.mkdir();
return newDir.toString();
}
示例14: copyRecursive
import java.io.File; //导入方法依赖的package包/类
public static boolean copyRecursive(
File from,
File to)
{
if (from.isDirectory()) {
if (!to.exists()) {
if (!to.mkdir()) {
return false;
}
}
for (String path : from.list()) {
if (!copyRecursive(new File(from, path), new File(to, path))) {
return false;
}
}
} else {
try {
InputStream in = new FileInputStream(from);
OutputStream out = new FileOutputStream(to);
byte[] buf = new byte[ConstantsUI.IO_BUFFER_SIZE];
copyStream(in, out, buf, ConstantsUI.IO_BUFFER_SIZE);
in.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
return true;
}
示例15: testescribeOfflineDiskStore
import java.io.File; //导入方法依赖的package包/类
@Test
public void testescribeOfflineDiskStore() {
setUpJmxManagerOnVm0ThenConnect(null);
final File diskStoreDir =
new File(new File(".").getAbsolutePath(), "DiskStoreCommandDUnitDiskStores");
diskStoreDir.mkdir();
this.filesToBeDeleted.add(diskStoreDir.getAbsolutePath());
final String diskStoreName1 = "DiskStore1";
final String region1 = "Region1";
final String region2 = "Region2";
final VM vm1 = Host.getHost(0).getVM(1);
vm1.invoke(new SerializableRunnable() {
public void run() {
final Cache cache = getCache();
DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
diskStoreFactory.setDiskDirs(new File[] {diskStoreDir});
final DiskStore diskStore1 = diskStoreFactory.create(diskStoreName1);
assertNotNull(diskStore1);
RegionFactory regionFactory =
cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT);
regionFactory.setDiskStoreName(diskStoreName1);
regionFactory.setDiskSynchronous(true);
regionFactory.create(region1);
regionFactory.setCompressor(SnappyCompressor.getDefaultInstance());
regionFactory.create(region2);
cache.close();
assertTrue(new File(diskStoreDir, "BACKUP" + diskStoreName1 + ".if").exists());
}
});
CommandResult cmdResult = executeCommand("describe offline-disk-store --name=" + diskStoreName1
+ " --disk-dirs=" + diskStoreDir.getAbsolutePath());
assertEquals(Result.Status.OK, cmdResult.getStatus());
String stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertTrue(stringContainsLine(stringResult, ".*/" + region1
+ ": -lru=none -concurrencyLevel=16 -initialCapacity=16 -loadFactor=0.75 -offHeap=false -compressor=none -statisticsEnabled=false -customAttrributes=null -regionMapFactory="));
assertTrue(stringContainsLine(stringResult, ".*/" + region2
+ ": -lru=none -concurrencyLevel=16 -initialCapacity=16 -loadFactor=0.75 -offHeap=false -compressor=org.apache.geode.compression.SnappyCompressor -statisticsEnabled=false -customAttrributes=null -regionMapFactory="));
cmdResult = executeCommand("describe offline-disk-store --name=" + diskStoreName1
+ " --disk-dirs=" + diskStoreDir.getAbsolutePath() + " --region=/" + region1);
stringResult = commandResultToString(cmdResult);
assertEquals(2, countLinesInString(stringResult, false));
assertTrue(stringContainsLine(stringResult, ".*/" + region1 + ": .*"));
assertFalse(stringContainsLine(stringResult, ".*/" + region2 + ": .*"));
}