當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。