本文整理匯總了Java中java.nio.file.Path.toRealPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Path.toRealPath方法的具體用法?Java Path.toRealPath怎麽用?Java Path.toRealPath使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.file.Path的用法示例。
在下文中一共展示了Path.toRealPath方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: testDeleteRecursively_nonDirectoryFile
點讚 3
import java.nio.file.Path; //導入方法依賴的package包/類
public void testDeleteRecursively_nonDirectoryFile() throws IOException {
try (FileSystem fs = newTestFileSystem(SECURE_DIRECTORY_STREAM)) {
Path file = fs.getPath("dir/a");
assertTrue(Files.isRegularFile(file, NOFOLLOW_LINKS));
MoreFiles.deleteRecursively(file);
assertFalse(Files.exists(file, NOFOLLOW_LINKS));
Path symlink = fs.getPath("/symlinktodir");
assertTrue(Files.isSymbolicLink(symlink));
Path realSymlinkTarget = symlink.toRealPath();
assertTrue(Files.isDirectory(realSymlinkTarget, NOFOLLOW_LINKS));
MoreFiles.deleteRecursively(symlink);
assertFalse(Files.exists(symlink, NOFOLLOW_LINKS));
assertTrue(Files.isDirectory(realSymlinkTarget, NOFOLLOW_LINKS));
}
}
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:22,
示例2: btn_kontrolActionPerformed
點讚 3
import java.nio.file.Path; //導入方法依賴的package包/類
private void btn_kontrolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_kontrolActionPerformed
// TODO add your handling code here:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("BP2_LAB2PU");
EntityManager em = emf.createEntityManager();
Query q = em.createQuery("SELECT m FROM Musteri m");
List musteriler = q.getResultList();
for (Musteri musteri : musteriler) {
Path p= Paths.get("musteriler\\"+musteri.getId()+".txt");
try {
p.toRealPath();
} catch (IOException ex) {
System.out.println(musteri.getId()+" numaralı müsteri dosyası bulunamadı");
}
}
}
開發者ID:sametkaya,項目名稱:Java_Swing_Programming,代碼行數:18,
示例3: pathToURLs
點讚 3
import java.nio.file.Path; //導入方法依賴的package包/類
/**
* Convert class path specification into an array of file URLs.
*
* The path of the file is converted to a URI then into URL
* form so that reserved characters can safely appear in the path.
*/
private static URL[] pathToURLs(String path) {
List paths = new ArrayList<>();
for (String entry: path.split(File.pathSeparator)) {
Path p = Paths.get(entry);
try {
p = p.toRealPath();
} catch (IOException x) {
p = p.toAbsolutePath();
}
try {
paths.add(p.toUri().toURL());
} catch (MalformedURLException e) {
//ignore / skip entry
}
}
return paths.toArray(new URL[0]);
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,
示例4: obtainLock
點讚 2
import java.nio.file.Path; //導入方法依賴的package包/類
@Override
public Lock obtainLock(@NonNull Directory dir, String lockName) throws IOException {
if (!(dir instanceof RedisDirectory)) {
throw new IllegalArgumentException("Expect argument of type [" + RedisDirectory.class.getName() + "]!");
}
Path lockFile = lockFileDirectory.resolve(lockName);
try {
Files.createFile(lockFile);
log.debug("Lock file path = {}", lockFile.toFile().getAbsolutePath());
} catch (IOException ignore) {
//ignore
log.debug("Lock file already exists!");
}
final Path realPath = lockFile.toRealPath();
final FileTime creationTime = Files.readAttributes(realPath, BasicFileAttributes.class).creationTime();
if (LOCK_HELD.add(realPath.toString())) {
FileChannel fileChannel = null;
FileLock lock = null;
try {
fileChannel = FileChannel.open(realPath, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
lock = fileChannel.tryLock();
if (lock != null) {
return new RedisLock(lock, fileChannel, realPath, creationTime);
} else {
throw new LockObtainFailedException("Lock held by another program: " + realPath);
}
} finally {
if (lock == null) {
IOUtils.closeQuietly(fileChannel);
clearLockHeld(realPath);
}
}
} else {
throw new LockObtainFailedException("Lock held by this virtual machine: " + realPath);
}
}
開發者ID:shijiebei2009,項目名稱:RedisDirectory,代碼行數:37,
示例5: jButton3ActionPerformed
點讚 2
import java.nio.file.Path; //導入方法依賴的package包/類
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
EntityManagerFactory emf=Persistence.createEntityManagerFactory("BP2_LAB2PU");
EntityManager em=emf.createEntityManager();
Query q=em.createQuery("SELECT k FROM Personel k");
Listpersoneller=q.getResultList();
// ArrayList paths=new ArrayList();
for (Personel personel : personeller) {
try {
// paths.add(personel.getAdi());
Path p =Paths.get(personel.getAdi());
p.toRealPath();
} catch (IOException ex) {
Logger.getLogger(Soru2.class.getName()).log(Level.SEVERE, null, ex);
}
}
//
// for (String path : paths) {
// try {
// Path p=Paths.get(path);
// p.toRealPath();
// } catch (IOException ex) {
// System.out.println(path+" Müşterisine Ait Bilgi Bulunamadı.");
// }
// }
}
開發者ID:sametkaya,項目名稱:Java_Swing_Programming,代碼行數:29,
示例6: normalize
點讚 2
import java.nio.file.Path; //導入方法依賴的package包/類
static Path normalize(Path p) {
try {
return p.toRealPath();
} catch (IOException e) {
return p.toAbsolutePath().normalize();
}
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,
示例7: getCanonicalFile
點讚 2
import java.nio.file.Path; //導入方法依賴的package包/類
public Path getCanonicalFile(Path file) {
try {
return file.toRealPath();
} catch (IOException e) {
return file.toAbsolutePath().normalize();
}
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,
示例8: set
點讚 1
import java.nio.file.Path; //導入方法依賴的package包/類
/**
* Helper to set a {@link Path} value correctly for use with {@link #overlayOn(Map,Config)}.
*
* @param overlay key-value pairs to overlay on a {@link Config}
* @param key key to set
* @param path {@link Path} value
* @throws IOException if {@link Path} can't be made canonical
*/
public static void set(Map overlay, String key, Path path) throws IOException {
Path finalPath = Files.exists(path, LinkOption.NOFOLLOW_LINKS) ?
path.toRealPath(LinkOption.NOFOLLOW_LINKS) :
path;
overlay.put(key, "\"" + finalPath.toUri() + "\"");
}
開發者ID:oncewang,項目名稱:oryx2,代碼行數:15,
注:本文中的java.nio.file.Path.toRealPath方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。