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


Java File.mkdirs方法代码示例

本文整理汇总了Java中java.io.File.mkdirs方法的典型用法代码示例。如果您正苦于以下问题:Java File.mkdirs方法的具体用法?Java File.mkdirs怎么用?Java File.mkdirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.File的用法示例。


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

示例1: onStartCommand

import java.io.File; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent.getBooleanExtra(PAUSE_DOWNLOAD, false)) {
        queue.pause();
        return START_REDELIVER_INTENT;
    }
    VideoDownLoadInfo video = (VideoDownLoadInfo) intent.getSerializableExtra(VIDEOS_INFO);
    EventBus.getDefault().postSticky(video,EventBusTags.CACHE_DOWNLOAD_BEGIN);
    videos.put(video.getId()+"",video);
    File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Sunny_Videos");
    if (!dir.exists()) {
        dir.mkdirs();
    }
    DaoMaster master = GreenDaoHelper.getInstance().create(video.getDbName()).getMaster();
    master.newSession().startAsyncSession().insertOrReplace(video);
    File file = new File(dir.getAbsolutePath(), video.getId() + ".mp4");
    BaseDownloadTask task = (FileDownloader.getImpl().create(video.getVideo().getPlayUrl()).setPath(file.getAbsolutePath()).setTag(video.getId()+""));
    task.setListener(new CommonDownloadListener());
    queue.enqueue(task);
    if (isInit){
        queue.resume();
        isInit = false;
    }
    return START_NOT_STICKY;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:26,代码来源:CacheDownLoadService.java

示例2: extract

import java.io.File; //导入方法依赖的package包/类
private void extract(BasicImageReader reader, String name,
        ImageLocation location) throws IOException, BadArgs {
    File directory = new File(options.directory);
    byte[] bytes = reader.getResource(location);
    File resource =  new File(directory, name);
    File parent = resource.getParentFile();

    if (parent.exists()) {
        if (!parent.isDirectory()) {
            throw TASK_HELPER.newBadArgs("err.cannot.create.dir",
                                        parent.getAbsolutePath());
        }
    } else if (!parent.mkdirs()) {
        throw TASK_HELPER.newBadArgs("err.cannot.create.dir",
                                    parent.getAbsolutePath());
    }

    if (!ImageResourcesTree.isTreeInfoResource(name)) {
        Files.write(resource.toPath(), bytes);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JImageTask.java

示例3: createFile

import java.io.File; //导入方法依赖的package包/类
private File createFile() {
    String dir = Environment.getExternalStorageDirectory() + "/winter/monitor";
    File dirFile = new File(dir);
    if (!dirFile.exists()) {
        dirFile.mkdirs();
    }
    SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.CHINESE);
    String a1 = dateformat1.format(new Date());
    File file = new File(dir + "/" + a1 + ".log");
    if (!file.exists()) {
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return file;
}
 
开发者ID:zongwu233,项目名称:Winter,代码行数:19,代码来源:InfoConsumer.java

示例4: testDynamicRegionFactoryDiskDir

import java.io.File; //导入方法依赖的package包/类
/**
 * @since GemFire 4.3
 */
@Test
public void testDynamicRegionFactoryDiskDir() throws CacheException {
  CacheCreation cache = new CacheCreation();
  File f = new File("diskDir");
  f.mkdirs();
  cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(f, null, true, true));
  RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
  cache.createRegion("root", attrs);
  // note that testXml can't check if they are same because enabling
  // dynamic regions causes a meta region to be produced.
  testXml(cache, false);
  assertEquals(true, DynamicRegionFactory.get().isOpen());
  assertEquals(f.getAbsoluteFile(), DynamicRegionFactory.get().getConfig().getDiskDir());
  Region dr = getCache().getRegion("__DynamicRegions");
  if (dr != null) {
    dr.localDestroyRegion();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:CacheXml66DUnitTest.java

示例5: writeStaticNodesFile

import java.io.File; //导入方法依赖的package包/类
protected void writeStaticNodesFile(String enodes) {
    try {
        File dir = new File(this.reactContext
                .getFilesDir() + STATIC_NODES_FILES_PATH);
        if (dir.exists() == false) dir.mkdirs();
        File f = new File(dir, STATIC_NODES_FILES_NAME);
        if (f.exists() == false) {
            if (f.createNewFile() == true) {
                WritableArray staticNodes = new WritableNativeArray();
                staticNodes.pushString(enodes);
                Writer output = new BufferedWriter(new FileWriter(f));
                output.write(staticNodes.toString());
                output.close();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:YsnKsy,项目名称:react-native-geth,代码行数:20,代码来源:GethHolder.java

示例6: getExternalCacheDir

import java.io.File; //导入方法依赖的package包/类
private static File getExternalCacheDir(Context context, String name) {
    File dataDir = new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data");
    File appCacheDir = new File(new File(dataDir, context.getPackageName()), "name");
    if (!appCacheDir.exists()) {
        if (!appCacheDir.mkdirs()) {
            return null;
        }

        try {
            (new File(appCacheDir, ".nomedia")).createNewFile();
        } catch (IOException var4) {
        }
    }

    return appCacheDir;
}
 
开发者ID:f-evil,项目名称:EVideoRecorder,代码行数:17,代码来源:StorageUtils.java

示例7: testFormatWithNonInteractive

import java.io.File; //导入方法依赖的package包/类
/**
 * Test namenode format with -format -nonInteractive options when a non empty
 * name directory exists. Format should not succeed.
 * 
 * @throws IOException
 */
@Test
public void testFormatWithNonInteractive() throws IOException {

  // we check for a non empty dir, so create a child path
  File data = new File(hdfsDir, "file");
  if (!data.mkdirs()) {
    fail("Failed to create dir " + data.getPath());
  }

  String[] argv = { "-format", "-nonInteractive" };
  try {
    NameNode.createNameNode(argv, config);
    fail("createNameNode() did not call System.exit()");
  } catch (ExitException e) {
    assertEquals("Format should have been aborted with exit code 1", 1,
        e.status);
  }

  // check if the version file does not exists.
  File version = new File(hdfsDir, "current/VERSION");
  assertFalse("Check version should not exist", version.exists());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestClusterId.java

示例8: setupConfigDir

import java.io.File; //导入方法依赖的package包/类
public static void setupConfigDir(File globalDir)
{
    configDir = new File(globalDir, WorldBorder.MODID);

    if ( !configDir.exists() && configDir.mkdirs() )
        Log.info("Created config directory for the first time");
}
 
开发者ID:abused,项目名称:World-Border,代码行数:8,代码来源:Config.java

示例9: testShellCommandProcess

import java.io.File; //导入方法依赖的package包/类
@org.junit.Test
public void testShellCommandProcess() throws Exception {
    NativeProcessBuilder npb = NativeProcessBuilder.newLocalProcessBuilder();
    File out = new File(getWorkDirPath(), "testShellCommandProcess");
    out.mkdirs();
    out.delete();
    try {
        npb.setCommandLine("echo TEST > \"" + out.getAbsolutePath() + "\"");
        NativeProcess process = npb.call();
        int rc = process.waitFor();

        if (!(process instanceof NbNativeProcess)) {
            System.out.println("Test testShellCommandProcess is not applicable for " + process.getClass().getName() + " - skipped");
            return;
        }


        assertEquals("echo with redirection status", 0, rc);

        BufferedReader br = new BufferedReader(new FileReader(out));
        StringBuilder sb = new StringBuilder();

        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        br.close();
        assertEquals("TEST is expected to be written in " + out.getAbsolutePath(), "TEST", sb.toString().trim());
    } finally {
        out.delete();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:NbStartLocalTest.java

示例10: createPath

import java.io.File; //导入方法依赖的package包/类
public static boolean createPath(String pathName){
    File file = new File(pathName);
    if(!file.exists()){
        boolean suc = file.mkdirs();
        return suc;
    }else{
        return true;
    }
}
 
开发者ID:gnaixx,项目名称:dex-hdog,代码行数:10,代码来源:FileUtil.java

示例11: getDirectory

import java.io.File; //导入方法依赖的package包/类
public File getDirectory(String targetProject, String targetPackage) throws ShellException {
    // targetProject is interpreted as a directory that must exist
    //
    // targetPackage is interpreted as a sub directory, but in package
    // format (with dots instead of slashes). The sub directory will be
    // created
    // if it does not already exist

    File project = new File(targetProject);
    if (!project.isDirectory()) {
        throw new ShellException(getString("Warning.9", targetProject));
    }

    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(targetPackage, ".");
    while (st.hasMoreTokens()) {
        sb.append(st.nextToken());
        sb.append(File.separatorChar);
    }

    File directory = new File(project, sb.toString());
    if (!directory.isDirectory()) {
        boolean rc = directory.mkdirs();
        if (!rc) {
            throw new ShellException(getString("Warning.10", directory.getAbsolutePath()));
        }
    }

    return directory;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:31,代码来源:AbstractShellCallback.java

示例12: saveDatabase

import java.io.File; //导入方法依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
private void saveDatabase(String jsonData) {
    try {
        File cachePath = new File(TallyStackerApplication.get().getCacheDir(), CHILD);
        cachePath.mkdirs();
        FileOutputStream stream = new FileOutputStream(cachePath + "/" + DATABASE_NAME);
        BufferedOutputStream bos = new BufferedOutputStream(stream);

        Exporter mExporter = new Exporter(bos);
        mExporter.writeJson(jsonData);
        mExporter.close();
        stream.close();
        File newFile = new File(cachePath, DATABASE_NAME);
        Uri contentUri = FileProvider.getUriForFile(mContext, "com.calebtrevino.tallystacker.file_provider", newFile);
        if (contentUri != null) {
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, "TallyStacker Database");
            shareIntent.putExtra(Intent.EXTRA_TEXT, "Please have a look");
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
            shareIntent.setType(mContext.getContentResolver().getType(contentUri));
            mContext.startActivity(Intent.createChooser(shareIntent, mContext.getResources().getText(R.string.send_to)));
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:31,代码来源:DatabaseDump.java

示例13: getExternalCacheDir

import java.io.File; //导入方法依赖的package包/类
private static String getExternalCacheDir(Context context) {
    File dir = context.getExternalCacheDir();
    if (dir == null) {
        return null;
    }
    if (!dir.mkdirs() && !dir.exists()) {
        return null;
    }
    return dir.getPath();
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:11,代码来源:XulSystemUtil.java

示例14: initProjectDirectoryFromWizard

import java.io.File; //导入方法依赖的package包/类
private File initProjectDirectoryFromWizard(Set<FileObject> projectRootDirectories) {
    File projectDirectory = (File) wizardDescriptor.getProperty(WizardProperty.PROJECT_DIR.key());
    if (projectDirectory != null) {
        projectDirectory = FileUtil.normalizeFile(projectDirectory);
    }
    projectDirectory.mkdirs();
    FileObject dir = FileUtil.toFileObject(projectDirectory);
    projectRootDirectories.add(dir);
    return projectDirectory;
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:11,代码来源:ImportWorker.java

示例15: createDiskCache

import java.io.File; //导入方法依赖的package包/类
private static synchronized DiskCache createDiskCache() {
    final Context context = NimUIKit.getContext();
    File cacheDir = StorageUtils.getOwnCacheDirectory(context, context.getPackageName() + "/cache/image/");
    if (!cacheDir.exists()) {
        cacheDir.mkdirs();
    }
    return DiskLruCacheWrapper.get(cacheDir, MAX_DISK_CACHE_SIZE);
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:9,代码来源:NIMGlideModule.java


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