本文整理汇总了Java中java.io.File.getAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:Java File.getAbsolutePath方法的具体用法?Java File.getAbsolutePath怎么用?Java File.getAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.getAbsolutePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadFrom
import java.io.File; //导入方法依赖的package包/类
/**
* download submission or assignment from server
* @param toDown assignment or submission to be downloaded
*/
private void downloadFrom(Assignment toDown ) {
client.sendUTFDataToServer("DOWNLOAD_SUBS");
client.sendObjectToServer(toDown);
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(this);
File downFolder = chooser.getSelectedFile();
byte[] data = (byte[]) client.getObjectFromServer();
try {
fos = new FileOutputStream(downFolder.getAbsolutePath() + "/" + toDown.getName() + ".zip");
fos.write(data);
fos.close();
} catch (IOException ex) {
Logger.getLogger(StudentMain.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例2: getChild
import java.io.File; //导入方法依赖的package包/类
public File getChild(File parent, String fileName) {
if (fileName.startsWith("\\")
&& !fileName.startsWith("\\\\")
&& isFileSystem(parent)) {
//Path is relative to the root of parent's drive
String path = parent.getAbsolutePath();
if (path.length() >= 2
&& path.charAt(1) == ':'
&& Character.isLetter(path.charAt(0))) {
return createFileObject(path.substring(0, 2) + fileName);
}
}
return super.getChild(parent, fileName);
}
示例3: getImageLabels
import java.io.File; //导入方法依赖的package包/类
public static File getImageLabels(@Nullable Context context) {
File dir = new File(FileUtils.getCacheDir(context).getAbsolutePath() + "/"
+ TF_CACHE_DIRECTORY);
if (!dir.exists()) dir.mkdir();
return new File(dir.getAbsolutePath() + "/"
+ "imagenet_comp_graph_label_strings.txt");
}
示例4: setDestinationInExternalFilesDir
import java.io.File; //导入方法依赖的package包/类
/**
* Set the local destination for the downloaded file to a path within
* the application's external files directory (as returned by
* {@link Context#getExternalFilesDir(String)}.
* <p>
* The downloaded file is not scanned by MediaScanner. But it can be
* made scannable by calling {@link #allowScanningByMediaScanner()}.
*
* @param context the {@link Context} to use in determining the external
* files directory
* @param dirType the directory type to pass to
* {@link Context#getExternalFilesDir(String)}
* @param subPath the path within the external directory, including the
* destination filename
* @return this object
* @throws IllegalStateException If the external storage directory
* cannot be found or created.
*/
public Request setDestinationInExternalFilesDir(Context context, String dirType,
String subPath) {
final File file = context.getExternalFilesDir(dirType);
if (file == null) {
throw new IllegalStateException("Failed to get external storage files directory");
} else if (file.exists()) {
if (!file.isDirectory()) {
throw new IllegalStateException(file.getAbsolutePath() +
" already exists and is not a directory");
}
} else {
if (!file.mkdirs()) {
throw new IllegalStateException("Unable to create directory: "+
file.getAbsolutePath());
}
}
setDestinationFromBase(file, subPath);
return this;
}
示例5: getAjavaCmd
import java.io.File; //导入方法依赖的package包/类
static String getAjavaCmd(String cmdStr) {
File binDir = new File(JavaHome, "bin");
File unpack200File = IsWindows
? new File(binDir, cmdStr + ".exe")
: new File(binDir, cmdStr);
String cmd = unpack200File.getAbsolutePath();
if (!unpack200File.canExecute()) {
throw new RuntimeException("please check" +
cmd + " exists and is executable");
}
return cmd;
}
示例6: OdsDll
import java.io.File; //导入方法依赖的package包/类
public OdsDll(String nativeDllPath) {
if (dllYetToBeInitialized) {
String actualNativeDllPath = "ods";
if (nativeDllPath != null) {
File nativeDllFileOrDir = new File(nativeDllPath);
if (!nativeDllFileOrDir.exists()) {
throw new RuntimeException("Invalid native DLL path: " + nativeDllFileOrDir.getAbsolutePath());
}
if (nativeDllFileOrDir.isDirectory()) {
actualNativeDllPath = nativeDllPath + "/ods";
} else {
actualNativeDllPath = nativeDllPath;
for (String ext : new String[]{ ".so", ".dll" }) {
if (actualNativeDllPath.toLowerCase().endsWith(ext))
actualNativeDllPath = actualNativeDllPath.substring(
0, actualNativeDllPath.length() - ext.length());
}
}
}
// Delft3D-Flow uses ifort for both linux and windows.
// If in the future another compiler is needed, e.g. gfortran,
// see org.openda.model_efdc_dll.EfdcDLL for an example of function name mapping.
if(BBUtils.RUNNING_ON_WINDOWS){
odsWinIfortDll = (OdsWinIfortDll) Native.loadLibrary(actualNativeDllPath, OdsWinIfortDll.class);
}else{
// GfortranFunctionMapper gFortranMapper = new GfortranFunctionMapper();
// HashMap<String, String> gFortranMap = gFortranMapper.getMap();
odsWinIfortDll = (OdsWinIfortDll) Native.loadLibrary(
actualNativeDllPath, OdsWinIfortDll.class); // , gFortranMap);
}
dllYetToBeInitialized = true;
}
}
示例7: saveData2SDCardPrivateFileDir
import java.io.File; //导入方法依赖的package包/类
/**
* 往SDCard的私有File目录下保存文件
*
* @param data
* @param type
* @param filename
* @param context
* @return
*/
public static boolean saveData2SDCardPrivateFileDir(byte[] data, String type, String filename, Context context) {
if (isSDCardMounted()) {
File path = context.getExternalFilesDir(type);
if (!path.exists()) {
path.mkdir();
}
String file = path.getAbsolutePath() + File.separator + filename;
try {
OutputStream os = new FileOutputStream(file);
os.write(data);
os.close();
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
示例8: createNewFile
import java.io.File; //导入方法依赖的package包/类
private static void createNewFile(File file_) {
if (file_ == null) {
return;
}
if (!(__createNewFile(file_)))
throw new RuntimeException(file_.getAbsolutePath()
+ " doesn't be created!");
}
示例9: getBlockSize
import java.io.File; //导入方法依赖的package包/类
private long getBlockSize() {
if (mBlockSize == 0L) {
File chatLogDir = mServerConfigManager.getChatLogDir();
if (!chatLogDir.exists())
return 0L;
StatFs statFs = new StatFs(chatLogDir.getAbsolutePath());
if (Build.VERSION.SDK_INT >= 18)
mBlockSize = statFs.getBlockSizeLong();
else
mBlockSize = statFs.getBlockSize();
}
return mBlockSize;
}
示例10: searchDirForPath
import java.io.File; //导入方法依赖的package包/类
public static String searchDirForPath(File dir, int bucketId) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
String path = file.getAbsolutePath();
if (GalleryUtils.getBucketId(path) == bucketId) {
return path;
} else {
path = searchDirForPath(file, bucketId);
if (path != null) return path;
}
}
}
}
return null;
}
示例11: ZipFile2
import java.io.File; //导入方法依赖的package包/类
/**
* This method does access the actual storage to get data about the file
*/
public ZipFile2(File file) {
if (file == null)
throw new IllegalArgumentException("file must not be null");
//remove file://
if(file.getAbsolutePath().startsWith("file://"))
mPath = file.getAbsolutePath().substring("file://".length());
else
mPath = file.getAbsolutePath();
mLength = file.length();
mIsFile = file.isFile();
mLastModified = file.lastModified();
}
示例12: onActivityResult
import java.io.File; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case AppConstants.REQUEST_IMAGE_CAPTURE:
try {
PhotoDescriptionTO photoDescriptionTO = currentMedicine.getPhotoDescriptionTO();
File fullSizePhoto = new File(photoDescriptionTO.getFullSizePhotoUri());
File smallSizePhoto = PhotoUtils.prepareSmallSizePhotoFile(fullSizePhoto);
String smallSizePhotoAbsolutePath = smallSizePhoto.getAbsolutePath();
photoDescriptionTO.setSmallSizePhotoUri(smallSizePhotoAbsolutePath);
setMedicineThumbnail(photoDescriptionTO);
} catch (Exception e) {
// Had to remove logs, becasue of google play
}
break;
case AppConstants.REQUEST_VOICE_INPUT_MEDICINE_NAME:
String potentialMedicineName = retrievePotentialMedicineNameFromVoiceRecognizedData(data);
if (!TextUtils.isEmpty(potentialMedicineName)) {
nameEdit.setText(potentialMedicineName);
}
break;
case AppConstants.REQUEST_VOICE_INPUT_MEDICINE_NOTES:
String potentialMedicineNotes = retrievePotentialMedicineNameFromVoiceRecognizedData(data);
if (!TextUtils.isEmpty(potentialMedicineNotes)) {
notesEdit.setText(potentialMedicineNotes);
}
break;
default:
break;
}
}
}
示例13: importTestData
import java.io.File; //导入方法依赖的package包/类
@Override
public CsvTestData importTestData(File file) {
CsvTestData csvData = new CsvTestData(file.getAbsolutePath());
csvData.loadTableModel();
csvData.setLocation(getLocation() + File.separator + file.getName());
csvData.saveChanges();
return csvData;
}
示例14: loadLibrary
import java.io.File; //导入方法依赖的package包/类
public void loadLibrary(String jarpath, Context context) {
this.context = context;
File jarfile = new File(jarpath);
if(!jarfile.exists())
throw new IllegalArgumentException("Could not find library: " + jarpath);
this.jarpath = jarpath;
File optimizedLibrarypath = context.getDir("dex", 0);
dexClassLoader = new DexClassLoader(jarpath, optimizedLibrarypath.getAbsolutePath(),
null, context.getClassLoader());
}
示例15: PipeDecoder
import java.io.File; //导入方法依赖的package包/类
public PipeDecoder(){
pipeBuffer = 10000;
//Use sensible defaults depending on the platform
if(System.getProperty("os.name").indexOf("indows") > 0 ){
pipeEnvironment = "cmd.exe";
pipeArgument = "/C";
}else if(new File("/bin/bash").exists()){
pipeEnvironment = "/bin/bash";
pipeArgument = "-c";
}else if (new File("/system/bin/sh").exists()){
//probably we are on android here
pipeEnvironment = "/system/bin/sh";
pipeArgument = "-c";
}else{
LOG.severe("Coud not find a command line environment (cmd.exe or /bin/bash)");
throw new Error("Decoding via a pipe will not work: Coud not find a command line environment (cmd.exe or /bin/bash)");
}
String path = System.getenv("PATH");
String arguments = " -ss %input_seeking% %number_of_seconds% -i \"%resource%\" -vn -ar %sample_rate% -ac %channels% -sample_fmt s16 -f s16le pipe:1";
if(isAvailable("ffmpeg")){
LOG.info("found ffmpeg on the path (" + path + "). Will use ffmpeg for decoding media files.");
pipeCommand = "ffmpeg" + arguments;
}else if (isAvailable("avconv")){
LOG.info("found avconv on your path(" + path + "). Will use avconv for decoding media files.");
pipeCommand = "avconv" + arguments;
}else {
if(isAndroid()) {
String tempDirectory = System.getProperty("java.io.tmpdir");
printErrorstream=true;
File f = new File(tempDirectory, "ffmpeg");
if (f.exists() && f.length() > 1000000 && f.canExecute()) {
decoderBinaryAbsolutePath = f.getAbsolutePath();
} else {
LOG.severe("Could not find an ffmpeg binary for your Android system. Did you forget calling: 'new AndroidFFMPEGLocator(this);' ?");
LOG.severe("Tried to unpack a statically compiled ffmpeg binary for your architecture to: " + f.getAbsolutePath());
}
}else{
LOG.warning("Dit not find ffmpeg or avconv on your path(" + path + "), will try to download it automatically.");
FFMPEGDownloader downloader = new FFMPEGDownloader();
decoderBinaryAbsolutePath = downloader.ffmpegBinary();
if(decoderBinaryAbsolutePath==null){
LOG.severe("Could not download an ffmpeg binary automatically for your system.");
}
}
if(decoderBinaryAbsolutePath == null){
pipeCommand = "false";
throw new Error("Decoding via a pipe will not work: Could not find an ffmpeg binary for your system");
}else{
pipeCommand = '"' + decoderBinaryAbsolutePath + '"' + arguments;
}
}
}