當前位置: 首頁>>代碼示例>>Java>>正文


Java File.separator方法代碼示例

本文整理匯總了Java中java.io.File.separator方法的典型用法代碼示例。如果您正苦於以下問題:Java File.separator方法的具體用法?Java File.separator怎麽用?Java File.separator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.File的用法示例。


在下文中一共展示了File.separator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: saveMeta

import java.io.File; //導入方法依賴的package包/類
public void saveMeta(String id, ObservationResult cur) {
	JsonObject meta = new JsonObject();
	meta.add("start", cur.getStart().getTime());
	meta.add("end", cur.getEnd().getTime());
	if (cur.getGain() != null) {
		meta.add("gain", cur.getGain());
	}
	if (cur.getChannelA() != null) {
		meta.add("channelA", cur.getChannelA());
	}
	if (cur.getChannelB() != null) {
		meta.add("channelB", cur.getChannelB());
	}
	File dest = new File(basepath, id + File.separator + "data" + File.separator + cur.getId() + File.separator + "meta.json");
	try (BufferedWriter w = new BufferedWriter(new FileWriter(dest))) {
		w.append(meta.toString());
	} catch (IOException e) {
		LOG.error("unable to write meta", e);
	}
}
 
開發者ID:dernasherbrezon,項目名稱:r2cloud,代碼行數:21,代碼來源:SatelliteDao.java

示例2: getSemaphoreFile

import java.io.File; //導入方法依賴的package包/類
/**
    * returns the Semaphore File
    * 
    * @return Semaphore File
    */
   public File getSemaphoreFile() {

String fileStr = System.getProperty("java.io.tmpdir");
if (!fileStr.endsWith(File.separator)) {
    fileStr += File.separator;
}

fileStr += ".kawansoft";
new File(fileStr).mkdir();

if (!fileStr.endsWith(File.separator)) {
    fileStr += File.separator;
}

fileStr += "kawanfw-web-server-semaphore-port." + port;
return new File(fileStr);
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:23,代碼來源:PortSemaphoreFile.java

示例3: getJavaRtPath

import java.io.File; //導入方法依賴的package包/類
public static String getJavaRtPath() {
 File rtFile = new File(System.getProperty("java.home") + 
	  File.separator + "lib" + File.separator + "rt.jar");
 
 if (!rtFile.exists()) {
  return null;
 }
 
 return rtFile.getAbsolutePath();
}
 
開發者ID:Samsung,項目名稱:MeziLang,代碼行數:11,代碼來源:PathUtil.java

示例4: writeScripts

import java.io.File; //導入方法依賴的package包/類
/** write the scripts necessary to run the project */
public boolean writeScripts(boolean debug, boolean useBuildFileName) {
    this.useBuildFileName = useBuildFileName;
    
    //if (hasCBuild()) {
    //    System.out.println("The build.xml file is not being created, the user c-build.xml file is used instead.");
    //    return true; // if the user has a c-build.xml file, use his build
    //}

    try {
        String script = Config.get().getTemplate("build-template.xml");

        // replace <....>
        script = replaceMarks(script, debug);

        // create bin dir
        File bindirfile = new File(project.getDirectory()+File.separator+bindir);
        if (!bindirfile.exists()) {
            bindirfile.mkdirs();
        }
            
        // write the script
        FileWriter out = new FileWriter(project.getDirectory() + File.separator + bindir + getBuildFileName());
        out.write(script);
        out.close();
        return true;
    } catch (Exception e) {
        System.err.println("Could not write start script for project " + project.getSocName());
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:nickrfer,項目名稱:code-sentinel,代碼行數:33,代碼來源:CentralisedMASLauncherAnt.java

示例5: getExtCacheDirectory

import java.io.File; //導入方法依賴的package包/類
public static String getExtCacheDirectory() {
    String uacCachepath = TextUtils.isEmpty(getExtCacheDirectory("uac")) ? getExternalImageCacheDir(ContextUtils.getContext()) : getExtCacheDirectory("uac");
    File photoFile = new File(uacCachepath);
    if (!photoFile.exists()) {
        photoFile.mkdir();
    }
    File nomediaFile = new File(uacCachepath + File.separator + ".nomedia");
    if (!nomediaFile.exists()) {
        nomediaFile.mkdir();
    }
    return uacCachepath;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:13,代碼來源:SystemUtils.java

示例6: updateOfFileReplace

import java.io.File; //導入方法依賴的package包/類
/**
 * 文件替換的升級操作
 * @param conf
 */
private void updateOfFileReplace(Map<String,Object> conf,String updateDir) throws IOException {
    if(conf != null){
        Set<String> keys = conf.keySet();//key是更新服務器上的文件
        for (String key : keys) {
            File updateFile = new File(updateDir + File.separator + key);
            String targetFile = String.valueOf(conf.get(key));//value是需要替換的目標文件
            targetFile = agentHome + File.separator + targetFile;

            //刪除需要替換的文件
            Path targetPath = Paths.get(targetFile);
            try(DirectoryStream<Path> stream = Files.newDirectoryStream(targetPath.getParent(),targetPath.getFileName().toString())){
                for (Path path : stream) {
                    if(!path.toFile().delete()){
                        log.error("{}old file '{}' deleted <FAILED>. update <FAILED>",log4UpdateStart,path);
                        return;
                    }
                }
            }catch (Exception e){
                log.error("",e);
            }

            FileUtils.copyFileToDirectory(updateFile,targetPath.getParent().toFile());
            log.info("{}replace file '{}' to dir '{}' <SUCCESS>",log4UpdateStart,updateFile.toPath().getFileName(),targetPath.getParent());
        }
    }
}
 
開發者ID:DevopsJK,項目名稱:SuitAgent,代碼行數:31,代碼來源:Update.java

示例7: deleteDirectory

import java.io.File; //導入方法依賴的package包/類
/**
 * 刪除目錄(文件夾)以及目錄下的文件
 * <p>
 * @param sPath 被刪除目錄的文件路徑
 * @return 目錄刪除成功返回true,否則返回false
 */
public static boolean deleteDirectory(String sPath) {
    //如果sPath不以文件分隔符結尾,自動添加文件分隔符
    if (!sPath.endsWith(File.separator)) {
        sPath = sPath + File.separator;
    }
    File dirFile = new File(sPath);
    //如果dir對應的文件不存在,或者不是一個目錄,則退出
    if (!dirFile.exists() || !dirFile.isDirectory()) {
        return false;
    }
    flag = true;
    //刪除文件夾下的所有文件(包括子目錄)
    File[] fs = dirFile.listFiles();
    for (File file : fs) {
        //刪除子文件
        if (file.isFile()) {
            flag = deleteFile(file.getAbsolutePath());
            if (!flag) {
                break;
            }
        } else { //刪除子目錄
            flag = deleteDirectory(file.getAbsolutePath());
            if (!flag) {
                break;
            }
        }
    }
    if (!flag) {
        return false;
    }
    //刪除當前目錄
    return dirFile.delete();
}
 
開發者ID:ajtdnyy,項目名稱:PackagePlugin,代碼行數:40,代碼來源:FileUtil.java

示例8: testArchiveFileExists

import java.io.File; //導入方法依賴的package包/類
/**
 * Tests that the configured archive file is created and exists.
 */
@Test
public void testArchiveFileExists() throws Exception {
  final String dir = this.testDir.getAbsolutePath();
  final String archiveFileName = dir + File.separator + this.testName.getMethodName() + ".gfs";

  final File archiveFile1 =
      new File(dir + File.separator + this.testName.getMethodName() + ".gfs");

  Properties props = createGemFireProperties();
  props.setProperty(STATISTIC_ARCHIVE_FILE, archiveFileName);
  connect(props);

  GemFireStatSampler statSampler = getGemFireStatSampler();
  assertTrue(statSampler.waitForInitialization(5000));

  final File archiveFile = statSampler.getArchiveFileName();
  assertNotNull(archiveFile);
  assertEquals(archiveFile1, archiveFile);

  waitForFileToExist(archiveFile, 5000, 10);

  assertTrue(
      "File name incorrect: archiveFile.getName()=" + archiveFile.getName()
          + " archiveFile.getAbsolutePath()=" + archiveFile.getAbsolutePath()
          + " getCanonicalPath()" + archiveFile.getCanonicalPath(),
      archiveFileName.contains(archiveFile.getName()));
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:31,代碼來源:GemFireStatSamplerIntegrationTest.java

示例9: init

import java.io.File; //導入方法依賴的package包/類
private void init() {
    isRoot = RootUtil.isRoot();
    if (!isRoot) {
        tvRootStatus.setVisibility(View.VISIBLE);
        return;
    }

    scriptStorePath = this.getCacheDir().getAbsolutePath();
    ZipUtil.unzip(this.getPackageCodePath(), SCRIPT_NAME, scriptStorePath);
    String cmd = "chmod 777 " + scriptStorePath + File.separator + Build.CPU_ABI + File.separator + SCRIPT_NAME;
    RootUtil.execRootCmd(cmd);
}
 
開發者ID:gnaixx,項目名稱:dex-hdog,代碼行數:13,代碼來源:MainActivity.java

示例10: add

import java.io.File; //導入方法依賴的package包/類
private void add(ChildData childData, boolean reload) throws IOException {
    String name = childData.getPath().substring(childData.getPath().lastIndexOf("/") + 1);
    byte[] data = childData.getData();
    File file = new File(
            SystemConfig.getHomePath() + File.separator + "conf",
            name);
    Files.write(data, file);
    //try to reload dnindex
    if (reload && "dnindex.properties".equals(name)) {
        DbleServer.getInstance().reloadDnIndex();
    }
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:13,代碼來源:BinDataPathChildrenCacheListener.java

示例11: openTextCache

import java.io.File; //導入方法依賴的package包/類
DataFileCache openTextCache(Table table, String source,
                            boolean readOnlyData,
                            boolean reversed) throws HsqlException {

    closeTextCache(table);

    if (!properties.isPropertyTrue(
            HsqlDatabaseProperties.textdb_allow_full_path)) {
        if (source.indexOf("..") != -1) {
            throw (Trace.error(Trace.ACCESS_IS_DENIED, source));
        }

        String path = new File(
            new File(
                database.getPath()
                + ".properties").getAbsolutePath()).getParent();

        if (path != null) {
            source = path + File.separator + source;
        }
    }

    TextCache c;
    int       type;

    if (reversed) {
        c = new TextCache(table, source);
    } else {
        c = new TextCache(table, source);
    }

    c.open(readOnlyData || filesReadOnly);
    textCacheList.put(table.getName(), c);

    return c;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:37,代碼來源:Log.java

示例12: createDir

import java.io.File; //導入方法依賴的package包/類
public static void createDir(String destDirName) {
	final File dir = new File(destDirName);
	if (dir.exists()) {// �ж�Ŀ¼�Ƿ����
		// System.out.println("Target dir already existed");
	}
	if (!destDirName.endsWith(File.separator)) {// ��β�Ƿ���"/"����
		destDirName = destDirName + File.separator;
	}
	if (dir.mkdirs()) {// ����Ŀ��Ŀ¼
		System.out.println("Succeeded to create dir" + destDirName);
	}
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:13,代碼來源:FileOperation.java

示例13: mergeCoverage

import java.io.File; //導入方法依賴的package包/類
private void mergeCoverage(File dir)
throws IOException
  {
  	for (File f: interpreter.getSourceFiles())
  	{
  		File cov = new File(dir.getPath() + File.separator + f.getName() + ".cov");
  		LexLocation.mergeHits(f, cov);
  		println("Merged coverage for " + f);
  	}
  }
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:11,代碼來源:CommandReader.java

示例14: renderCustomTypePaper

import java.io.File; //導入方法依賴的package包/類
@Test
public void renderCustomTypePaper() throws Exception {
    // setup
    config.setProperty("template.paper.file", "paper." + templateExtension);
    DocumentTypes.addDocumentType("paper");
    DBUtil.updateSchema(db);

    Crawler crawler = new Crawler(db, sourceFolder, config);
    crawler.crawl(new File(sourceFolder.getPath() + File.separator + "content"));
    Parser parser = new Parser(config, sourceFolder.getPath());
    Renderer renderer = new Renderer(db, destinationFolder, templateFolder, config);
    String filename = "published-paper.html";

    File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + "papers" + File.separator + filename);
    Map<String, Object> content = parser.processFile(sampleFile);
    content.put(Crawler.Attributes.URI, "/" + filename);
    renderer.render(content);
    File outputFile = new File(destinationFolder, filename);
    Assert.assertTrue(outputFile.exists());

    // verify
    String output = FileUtils.readFileToString(outputFile);
    for (String string : getOutputStrings("paper")) {
        assertThat(output).contains(string);
    }

}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:28,代碼來源:GroovyMarkupTemplateEngineRenderingTest.java

示例15: getDiskCacheDir

import java.io.File; //導入方法依賴的package包/類
/**
 * 獲取緩存目錄
 * @param mContext
 * @param bitmap
 * @return
 */
private File getDiskCacheDir(Context mContext, String bitmap) {
    boolean externalStorageAvailable = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    String cachePath;
    if (externalStorageAvailable) {
        cachePath = mContext.getExternalCacheDir().getPath();
    } else {
        cachePath = mContext.getCacheDir().getPath();
    }
    return new File(cachePath + File.separator + bitmap);
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:17,代碼來源:ImageLoader.java


注:本文中的java.io.File.separator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。