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


Java File.getAbsoluteFile方法代码示例

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


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

示例1: saveInternalState

import java.io.File; //导入方法依赖的package包/类
public IModelState saveInternalState() {


			// Create model instance state files, and add them state files to model state
			FileBasedModelState algorithmState = new FileBasedModelState();
			algorithmState.setDirContainingModelstateFiles(dirForPersistentModelStates);

			ArrayList<File> modelInstanceDirs = listModelInstanceDirs();
			for (int i = 0; i < modelInstanceDirs.size(); i++) {
				File modelInstanceDir = modelInstanceDirs.get(i);
				IModelState modelInstanceState = modelInstance_saveInternalState(modelInstanceDir);
				File modelStateFile = new File(dirForPersistentModelStates, modelInstanceDir.getName() + zippedModelStateFileExtension);
				File fileToBeAddedToState;
				if (i == 1) {
					// test absolute path
					fileToBeAddedToState = modelStateFile.getAbsoluteFile();
				} else {
					// test relative path
					fileToBeAddedToState = modelStateFile;
				}
				modelInstanceState.savePersistentState(fileToBeAddedToState);
				algorithmState.addFile(fileToBeAddedToState);
			}
			return algorithmState;
		}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:26,代码来源:FileBasedModelStateTest.java

示例2: getRecordFile

import java.io.File; //导入方法依赖的package包/类
/**
 * Get the file to record to for a given remote contact. This will
 * implicitly get the current date in file name.
 * 
 * @param remoteContact The remote contact name
 * @return The file to store conversation
 */
private File getRecordFile(File dir, String remoteContact, int way) {
    if (dir != null) {
        // The file name is only to have an unique identifier.
        // It should never be used to store datas as may change.
        // The app using the recording files should rely on the broadcast
        // and on callInfo instead that is reliable.
        String datePart = (String) DateFormat.format("yy-MM-dd_kkmmss", new Date());
        String remotePart = sanitizeForFile(remoteContact);
        String fileName = datePart + "_" + remotePart;
        if (way != (SipManager.BITMASK_ALL)) {
            fileName += ((way & SipManager.BITMASK_IN) == 0) ? "_out" : "_in";
        }
        File file = new File(dir.getAbsoluteFile() + File.separator
                + fileName + ".wav");
        return file;
    }
    return null;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:26,代码来源:SimpleWavRecorderHandler.java

示例3: contains

import java.io.File; //导入方法依赖的package包/类
public boolean contains(File file) {
    File absoluteFile = file.getAbsoluteFile();
    String pathWithSeparator = file.getAbsolutePath() + File.separator;
    for (File candidateFile : files) {
        String candidateFilePathWithSeparator = candidateFile.getPath() + File.separator;
        if (pathWithSeparator.startsWith(candidateFilePathWithSeparator)) {
            return true;
        }
    }

    for (DirectoryTree tree : trees) {
        if (tree.getDir().getAbsoluteFile().equals(absoluteFile) || DirectoryTrees.contains(FileSystems.getDefault(), tree, absoluteFile)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:FileSystemSubset.java

示例4: getAudioTmpFile

import java.io.File; //导入方法依赖的package包/类
/**
 * 获取声音文件的本地地址
 *
 * @param isTmp 是否是缓存文件, True,每次返回的文件地址是一样的
 * @return 录音文件的地址
 */
public static File getAudioTmpFile(boolean isTmp) {
    File dir = new File(getCacheDirFile(), "audio");
    //noinspection ResultOfMethodCallIgnored
    dir.mkdirs();
    File[] files = dir.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            //noinspection ResultOfMethodCallIgnored
            file.delete();
        }
    }

    // aar
    File path = new File(getCacheDirFile(), isTmp ? "tmp.mp3" : SystemClock.uptimeMillis() + ".mp3");
    return path.getAbsoluteFile();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:23,代码来源:Application.java

示例5: zipFolder

import java.io.File; //导入方法依赖的package包/类
private File zipFolder(File folder, String name) throws IOException {
	File zipFile = new File(tempFolder, name + ".zip");
	File source = folder.getAbsoluteFile();
	Set<String> fileSet = createFileSet(folder, source);
	ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
	
	byte[] buffer = new byte[1024];
	for (String file : fileSet) {
		ZipEntry ze = new ZipEntry(file);
		zos.putNextEntry(ze);
		FileInputStream fis = new FileInputStream(source + File.separator
				+ file);
		int len;
		while ((len = fis.read(buffer)) > 0) {
			zos.write(buffer, 0, len);
		}
		fis.close();
	}
	zos.closeEntry();
	zos.close();
	return zipFile;
}
 
开发者ID:NeoRoy,项目名称:KeYExperienceReport,代码行数:23,代码来源:ZipUtil.java

示例6: createRecursiveFolder

import java.io.File; //导入方法依赖的package包/类
/** Creates new folder and all necessary subfolders
*  @param f folder to create
*  @return <code>true</code> if the file exists when returning from this method
*/
private static boolean createRecursiveFolder(File f) {
    if (f.exists()) {
        return true;
    }

    if (!f.isAbsolute()) {
        f = f.getAbsoluteFile();
    }

    String par = f.getParent();

    if (par == null) {
        return false;
    }

    if (!createRecursiveFolder(new File(par))) {
        return false;
    }

    f.mkdir();

    return f.exists();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:LocalFileSystem.java

示例7: getDexmakerCacheDir

import java.io.File; //导入方法依赖的package包/类
private File getDexmakerCacheDir(){
    File cacheDir = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cacheDir = getApplication().getCodeCacheDir();
    } else {
        cacheDir = getApplication().getCacheDir();
    }
    File pandCache =  new File(cacheDir.getAbsoluteFile() + "/pand");
    if(!pandCache.exists()){
        pandCache.mkdir();
    }
    return pandCache;
}
 
开发者ID:FlavioSantoro92,项目名称:Pand,代码行数:14,代码来源:Pand.java

示例8: loadConfigValues

import java.io.File; //导入方法依赖的package包/类
private ConfigValues loadConfigValues(File file) {
	ConfigValues configValues = new ConfigValues();
	try {
		configValues.setRaw(new String(Files.readAllBytes(file.toPath()), "UTF-8"));
	}
	catch (IOException e) {
		throw new IllegalArgumentException("Could read values file " + file.getAbsoluteFile(), e);
	}
	return configValues;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:11,代码来源:DefaultPackageReader.java

示例9: writeInfo

import java.io.File; //导入方法依赖的package包/类
/** 寫入資料**/
public void writeInfo(String fileName, String strWrite) {
    //WRITE_EXTERNAL_STORAGE
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                WRITE_EXTERNAL_STORAGE_REQUEST_CODE);
    }
    try {

        String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath();
        String savePath = fullPath + File.separator + "/" + fileName;

        File file = new File(savePath);

        if (!file.exists()) {
            file.createNewFile();
        }

        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(strWrite);

        bw.close();

    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:qwe321qwe321qwe321,项目名称:NFC-UID-Emulator,代码行数:30,代码来源:MainActivity.java

示例10: getPortraitTmpFile

import java.io.File; //导入方法依赖的package包/类
public static File getPortraitTmpFile() {
    // 得到头像目录的缓存地址
    File dir = new File(getCacheDirFile(), "portrait");
    // 创建所有的对应的文件夹
    dir.mkdir();
    File[] files = dir.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            file.delete();
        }
    }
    // 返回一个当前时间的目录文件地址
    File path = new File(dir, SystemClock.uptimeMillis()+".jpg");
    return path.getAbsoluteFile();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:16,代码来源:Application.java

示例11: setupTestDirs

import java.io.File; //导入方法依赖的package包/类
@BeforeClass
public static void setupTestDirs() throws IOException {
  testDir = new File("target",
      TestSharedCacheUploaderService.class.getCanonicalName());
  testDir.delete();
  testDir.mkdirs();
  testDir = testDir.getAbsoluteFile();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestSharedCacheUploaderService.java

示例12: getInstance

import java.io.File; //导入方法依赖的package包/类
/**
 * 获取缓存实例
 * <p>在cacheDir目录</p>
 *
 * @param cacheDir 缓存目录
 * @param maxSize  最大缓存尺寸,单位字节
 * @param maxCount 最大缓存个数
 * @return {@link CacheUtils}
 */
public static CacheUtils getInstance(@NonNull final File cacheDir, final long maxSize, final int maxCount) {
    final String cacheKey = cacheDir.getAbsoluteFile() + "_" + Process.myPid();
    CacheUtils cache = CACHE_MAP.get(cacheKey);
    if (cache == null) {
        cache = new CacheUtils(cacheDir, maxSize, maxCount);
        CACHE_MAP.put(cacheKey, cache);
    }
    return cache;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CacheUtils.java

示例13: generateHtmlFile

import java.io.File; //导入方法依赖的package包/类
private static URL generateHtmlFile() {
    File file = new File("hello.html");
    try (
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);) {
        bw.write("<head></head><body>Hello World!</body>");
        return file.toURI().toURL();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:bug8031109.java

示例14: getIncomingBuilder

import java.io.File; //导入方法依赖的package包/类
public HierarchicalDirectoryBuilder getIncomingBuilder()
{
   File root = new File(path);
   if (!root.exists())
   {
      root.mkdirs();
   }
   return new HierarchicalDirectoryBuilder(root.getAbsoluteFile(), this.maxFileNo);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:10,代码来源:HfsManager.java

示例15: save

import java.io.File; //导入方法依赖的package包/类
public void save(File file) throws IOException
{
    File parent = file.getParentFile();

    if (((parent == null) || parent.exists() || parent.mkdirs()) && (file.exists() || file.createNewFile()))
    {
        try (FileWriter fileWriter = new FileWriter(file.getAbsoluteFile()))
        {
            BufferedWriter bw = new BufferedWriter(fileWriter);
            bw.write(json());
            bw.close();
        }
    }
}
 
开发者ID:mauriciotogneri,项目名称:stewie,代码行数:15,代码来源:Swagger.java


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