当前位置: 首页>>代码示例>>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;未经允许,请勿转载。