Can New Java 7 File API Path Objs Be Used For Windows Virtual Folders

Hello,
I'm trying to duplicate a JFileChooser's drop-down list containing root directories of the file system. For Windows machines, its combobox lists the roots in a nice tree-like layout. For example:
+ Desktop
  + Computer
    + Local Disk (C:)
    + Data (D:)I cannot find an offical way to do this; I ended up using a class called "ShellFolder" to do it. Based on the "File" objects returned by the "ShellFolder" operation, I wanted to use the "toPath" method of the "java.io.File" object to convert the object to a "java.io.file.Path" object. Unfortunately, when I try to convert it, a java.nio.file.InvalidPathException" occurs.
Therefore, is there a way to use the the new Path object (provided by Java7's new File NIO APIs) that can map to Windows special virtual folders (like "My Computer" which is mapped to a CLSID like "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")?
Note: It looks like NetBeans suffered from the same problem. See their bug report here: [https://netbeans.org/bugzilla/show_bug.cgi?id=214011] .
Here's some sample code to reproduce the problem:
static public void main(final String[] asArguments)
     javax.swing.SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run()
               java.io.File homeFile = FileSystemView.getFileSystemView().getHomeDirectory();
               System.out.printf("File obj for home dir = %s\r\n", homeFile.getAbsolutePath());
               java.nio.file.Path homePath = homeFile.toPath();
               System.out.printf("Path obj for home dir = %s\r\n", homePath.toString());
               // get the root directories
               java.io.File[] rootDirs = (java.io.File[]) sun.awt.shell.ShellFolder.get("fileChooserComboBoxFolders");
               for (int nIdx = 0; nIdx < rootDirs.length; nIdx++) {
                    java.io.File nextRoot = rootDirs[nIdx];
                    System.out.printf("File obj for next root dir = %s\r\n", nextRoot.getAbsolutePath());
                    // Is this a bug?
                    //          When we encounter a special Windows folder,
                    //          like "My Computer" which has a filename of "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
                    //          why do we receive a "java.nio.file.InvalidPathException"?  Should it not resolve the path
                    //          to the virtual Windows folder of "My Computer", just like the java.io.File objects do?
                    //          If not, is there an alternative way to get that information using the new Java 7 File APIs?
                    java.nio.file.Path nextRootPath = nextRoot.toPath();
                    System.out.printf("Path obj for next root dir = %s\r\n", nextRootPath.toString());
               } // for
          } // run
} // mainEdited by: RhinoGuy on Aug 10, 2012 11:11 AM

Hmm don't know about special folders but the File object does have a listRoots() method. Perhaps that only returns mapped drives on Windows though, I remember using it to create my own Eclipse type filechooser which I find a lot more user-friendly than the standard JFileChooser.

Similar Messages

  • Can I drag files to an external drive used for Time Machine to store them?

    Is that possible without doing partition? if so, what's the difference (with partition and without)? I'm undecided on whether to partition or not. Thanks!

    stellamaris5 wrote:
    Sorry to chip in - I'm having a similar issue.
    Aaargh.
    I want to delete about 8Gb worth of data from my internal HD on my iMac. Will I still have a copy in time machine?
    For a while, until time machine runs out of space and deletes its copy.
    Is timemachine then deleting them from the TM backup disk if they are gone from the internal HD.
    Eventually, yes.
    I have done a similar thing as the OP and cut the 8Gb folder from my MacHD and pasted it into the external disk where TM is doing its backups.
    Then you are wallowing in a state of sin.
    1. Should I leave it like that?
    No.
    or
    2. should I cut and paste it back into my MacHD, leave TM to do a few backups and then completely delete it from my MacHD?
    Neither. If you want to keep it, keep it on your MacHD, if you want to delete it delete it. Leave the Time Machine disk the **** alone.
    Thanks
    Not at all.

  • Java 8: Pb with new java.time api

    Hello,
    I'm trying to use the new java.time api that comes with Java 8 (I already know joda-time).
    I'm using the latest build B124.
    I've a String "01/08/2012_00:00:01", I know that the time ref. is UTC, and I want to convert it to an 'Instant';
    I tried:
    DateTimeFormatter FORMAT_DT = DateTimeFormatter.ofPattern("dd/MM/yyyy_HH:mm:ss").withZone(ZoneOffset.UTC);
    Instant instant = Instant.from(FORMAT_DT.parse("01/08/2012_00:00:01"));
    But it fails with following error:
    java.time.DateTimeException: Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 2012-08-01T00:00:01 of type java.time.format.Parsed
         at java.time.Instant.from(Unknown Source)
    I don't understand what's wrong with my code, and I can't figure out how I should proceed to convert the String to an Instant ...
    Any suggestion welcome,
    Best regards,
    Bernard.

    Originally you stated this:
    I don't understand what's wrong with my code,
    So naturally we focused on how to "understand what's wrong' with your code.
    You will never learn to troubleshoot problems if you just throw your hands up in the air and ask for help just because a complex series of steps doesn't complete successfully. 
    Break the process into its individual steps and check the results of each step to identify which step is FIRST producing an error.
    When a complex or multi-step process has an error you start checking the individual steps of the process to see how far it gets successfully.
    I would expect that converting a String to an Instant should be a basic/simple need, so it should be possible to do it in two lines of code; for the time being, the only way I found is to use a LocalDateTime intermediate variable, which seems quite verbose, and I'm wondering if someone knows a better way to do it, and would be willing to share it here.
    Just a technical distinction: your latest example using a LocalDateTime intermediate variable CAN be done in one line of code by just using dot-notation to avoid creating an explicit intermediate variable. But that variable will still be created implicitly behind the scenes.
    Converting a String to an Instant might be considered a basic/simple need but the set of functionality related to dealing with times, dates, calendars, etc is extremely complex. It makes much more sense to develop the requisite functionality in modules.
    Especially when introducing new functionality such as the 'Instant' class are related package elements introduced in 1.8. That functionality builds on what came before and parsers already existing that know how to deal with all of the possible String variants and formatting options and so on.
    Since that work CAN BE done on-the-fly using dot notation and anonymous implicit intermediate classes there isn't much need to reinvent that functionality in the new classes. If certain uses become standard new methods can always be added (e.g. to the Instant class) that will 'appear' to do things in one step.
    And, being an early adopter release, you can always file a 'bug' or enhancement request from the 1.8 download page. That page has links for 'Report Bugs' and 'Feedback forum' that you can use.
    In this current forum no one can give you an 'official' answer as to why something was implemented a particular way and/or whether that implementation is a 'bug' or was designed to work that way. Only Oracle can do that.

  • How can i upload files in servlets and also using jsp

    means that uploading files(.doc) or any files by using servlets and jsps

    yawmark wrote:
    saichand wrote:
    means that uploading files(.doc) or any files by using servlets and jsps
    [http://www.google.com/search?q=How+can+i+upload+files+in+servlets+and+also+using+jsp]
    ~Good topic titles are indeed brilliant search keywords. It's sad to see that it won't even come in the mind of the topicstarters to Google it before posting the topic.

  • Deploying manually CC PKG file built with CC Packager. Not using any third party deployment tool. However after each 5 installations, the PKG files corrupt and cannot be use for a 6th installation. I have to build a new PKG file using CC packager.  Why ?

    Deploying manually CC PKG file built with CC Packager. Not using any third party deployment tool. However after each 5 installations, the PKG files corrupt and cannot be use for a 6th installation. I have to build a new PKG file using CC packager.  Why ?

    http://helpx.adobe.com/creative-cloud/packager.html
    http://forums.adobe.com/community/download_install_setup/creative_suite_enterprise_deploym ent

  • Recently when creating a new blank page, application freezes. have been using for years without a problem. Upgrade?

    recently when creating a new blank page, application freezes. have been using for years without a problem. Upgrade?

    When something that used to work stops doing so, the most likely culprit is corrupt preferences. Go to HD > Users > (your account) > Library > Preferences, delete the com.apple.iwork.pages.plist file & then restart Pages. In Finder, hold down the Option key while clicking on the Go menu & your user Library will appear about halfway down the list. Or you can choose Go to Folder from the Go menu in Finder & paste this line in the box:
    ~/Library/Preferences

  • I have Mac Pro 2007, which have no bluetooth hardware. What should I do to use Apple wireless keyboard and magic mouse??? Can 'third party's internal bluetooth card' be used for this purpose? Help please...

    I have Mac Pro 2007, which have no bluetooth hardware. What should I do to use Apple wireless keyboard and magic mouse??? Can 'third party's internal bluetooth card' be used for this purpose? Help me please...

    You can find the Apple Bluetooth card on eBay for as little ten dollars (says its for the 2008 model Mac Pro, not sure about the 2007).
    http://www.ebay.com/itm/Bluetooth-Board-iMac-and-Mac-Pro-922-8233-922-8233-/1208 49278570
    Here is a link to a full explanation of the card and how to install it. Part numbers may differ a bit as that is an old article and newer models have come out.
    http://www.xlr8yourmac.com/systems/Mac_Pro/Bluetooth_MacPro_install/Bluetooth_Ma cPro_install.html
    Just make sure that the part will work in your model Mac Pro. To that end, you may be better off avoiding eBay and going to a parts reseller. There are even third party cards that use the internal Apple bluetooth slot.
    http://fastmac.com/bluetooth.php
    In theory, using a USB or PCI card will work at login so long as it is recognized by Apples drivers. You say you need to launch an application to use your current USB Bluetooth dongle? If it is not controlled by the Bluetooth icon in the menu bar then it must be using a third party driver of some sort. Unfortunately, I don't know off hand which USB and PCI cards are supported.

  • Installing Image Mastering API v2.0 (IMAPIv2.0) for Windows XP (KB932716) error

    I keep receiving this error when trying to run or save the download for Image Mastering API v2.0 (IMAPIv2.0) for Windows XP (KB932716):
    Internet Explorer cannot download ...XP-KB932716-v2-x86-ENU.exe from download.microsoft.com.
    The connection with the server was reset
    I have tried the download numerous times. Any Ideas?

    It works, but a newer update is available anyways, that includes Blu-ray media support.
    See KB952011 explaining that Image Mastering API v2.0 is included in the
    download   Windows Feature Pack for Storage 1.0 
    IMAPI_XP_SRV2003_x86.exe

  • HT5278 Can I download IOS 5.1.1 to use for several iPhone's -How...?

    Can I download IOS 5.1.1 to use for several iPhone's -How...?

    torrak1 wrote:
    So, that you are telling me, is that I should "download only" and not "download and update".
    No I'm not saying that.  For the first iPhone you can "download an update", then the 2nd one would be just "update" since the iOS file has already been downloaded (and "update" would be the only option for #2 since iTunes knows iOS has already been downloaded).  Of course you can also "download only" and then "update" each iPhone at a later time, your choice.
    As far as where the iOS files live, assuming you use a PC take a look here:
    C:\Documents and Settings\(account name)\Application Data\Apple Computer\iTunes\iPod Software Updates
    Look for the .ipsw and .signature files with 5.1.1 in the name.  If you need to copy this to a 2nd PC to save your download time and cost, just copy these files to the same location on the other computer before launching iTunes.

  • Have a new mac desktop that I want to use for syncing i-pad currently synced with old pc which I will be sicarding.  How do I switch computers with my I-pad??

    have a new mac desktop that I want to use for syncing i-pad.  Currently synced to an old pc that I will not be using any
    longer How do I switch computers for syncing?

    The absolute best way to do this is to transfer your iTunes library from the old computer to the new one. You can find a numbr of ways to do that here.
    http://www.google.com/search?client=safari&rls=en&q=transfer+iTunes+library+to+a nother+computer&ie=UTF-8&oe=UTF-8
    If you want to spend the money for a computer application that will let you transfer all of the content from the iPad to iTunes - look at
    Touchcopy
    However, I have posted this many times over the past few months. If you follow these instructions you should be fine. This will transfer the purchased content from the iPad into iTunes on the Mac. You will still want to get your photo library and any CD's that you imported into iTunes on the new Mac. That is why transferring the iTunes library to the new Mac is the best way to go.
    When you set up the new Mac - if you can import or migrate all of the PC content onto the Mac - this will all be a non issue, but I'm not sure how to bring all of your PC content onto the Mac. Going from an old Mac to a new Mac was a breeze, but I know nothing about transferring the content from a Windows PC.
    The 3 basic things to remember - authorize the computer, (Launch iTunes on your computer and go to Store>Authorize this Computer) transfer purchased content and backup.
    The following was copied from this thread. This is essentially what you want to accomplish.
    https://discussions.apple.com/message/11527071#11527071
    1) Without connecting your iPad to your Mac, start iTunes. Click on iTunes. Click on Preferences. Click on Devices. Check the box next to "Prevent your iPod etc. from automatically syncing." Click OK.
    2) Now connect your iPad to your Mac and start iTunes.
    3) When iTunes starts, right click on your iPad under Devices in the left column. Select Transfer purchases etc.
    4) After it finishes transferring all your apps to your new laptop, right click on your iPad and select Backup your iPad.
    5) After it finishes backing up your iPad, right click on your iPad and select Restore etc.
    6) After it finishes restoring, left click on your iPad , then click on the Apps tab on top, and check the box next to Sync Apps, then click on Apply below.
    If everything on your iPad looks good after the sync, go back and click on iTunes / Preferences / Devices and UN-check the box next to Prevent your iPod etc. The only other thing you may want to check is if your contacts, bookmarks, etc. are syncing correctly now. If not, go to the Info tab after connecting and make sure you indicate which features you want to sync with what sources.
    Read this thread and the support links as well. There are apps that you can purchase that will allow you to transfer photos from the iPad to your PC. Look at Photo Transfer App in the App store and you can search for others as well.
    https://discussions.apple.com/message/13016026#13016026
    This support site will help you with transferring iTunes music to your new computer - if you have an iTunes library of music on another computer or hard drive.
    http://support.apple.com/kb/HT4527
    The worst case scenario is that you can download all of your apps again if needed - but you will not retain the data or app settings - but it is always an option if everything else fails - but it won't fail!

  • In time capsule, can ethernet ports used for windows pc as a LAN?

    in time capsule, can ethernet ports used for windows pc as a LAN?

    i am connecting my windows pc to the time capsule ethernet prots but those pcs are not shown in my macbook or those windows pc also can not see my macbook pro. i am facing the problem...

  • Where can I find the update "Adobe Extension Manager CS5" for Windows? HELP!!!

    Where can I find the update "Adobe Extension Manager CS5" for Windows? HELP!!!

    Hi Piotrmp006,
    You can download the Extension Manager CS5 for Windows from the below mentioned link.
    Download the Extension Manager
    Download Extension Manager CS5 installer and save it on your machine.
    Double-click the installer to begin the installation process.
    Adobe - Exchange : Download the Adobe Extension Manager
    Let me know if you need more help.
    Thanks!
    Eshant

  • How can I download a Generic Post Script printer Driver  for Windows 7 .

    How can I download a Generic Post Script printer Driver  for Windows 7

    We used to install this PostScript printer  for previous Windows releases from
    (winsteng) and run it to install the driver from the below location
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=1500
    This doesnt work with Win 7 (The install crashes ) , Basically looking to do the same process with Win 7

  • How can we find out the disk which is used for a mount point

    How can we find out the disk which is used for a mount point?
    one of our mount point(/u03/oracle/prod) was using high I/O and this was causing slowness in the server.
    I can see a disk operation error in errpt at the same time as below. Wanted to check whether the mount point /u03/oracle/prod is using the disk hdisk31
    $errpt|more
    IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
    DXB78877 1125032114 T H hdisk31 DISK OPERATION ERROR
    OS version:AIX 6.1
    DB:11.2.0.2

    this is the output for cat /etc/filesystem
    /u02:
            dev             = /dev/fslv00
            vfs             = jfs2
            log             = /dev/loglv00
            mount           = true
            options         = rw
            account         = false
    /u01:
            dev             = /dev/fslv01
            vfs             = jfs2
            log             = /dev/loglv00
            mount           = true
            options         = rw
            account         = false

  • Can ethernet ports be used for windows pc as a LAN so that i can share all documents through it?

    can ethernet ports be used for windows pc as a LAN so that i can share all documents through it?

    The current 27-inch iMac can. Other iMac models can't outside of a VNC setup or ScreenRecycler; all such solutions require a standalone monitor for setup and troubleshooting.
    (51433)

Maybe you are looking for

  • WLS 10.3.1 Managed Server + WLS 10.3.3 AdminServer

    I have installed WLS 10.3.3 on Solaris. I have installed WLS 10.3.1 on Windows. I have created a domain in 10.3.3 version. I would like to create a managed server on 10.3.1 installation. Is this possible?+ When I tried I got the following error: *<Ma

  • Give access only one form module for a particular person.

    i have four form module like accounts,import,export,HR, each module has number of menus. I have to give a person to access only the module(accounts). when that particular person login into home page, he has to see the accounts module only. How to do

  • New episodes not appearing in iTunes store

    Arrogant - typed this in once and lost it! Anyway - for some reason the iTunes store hasn't updated to reflect two new podcast episodes. It seems the feed hasn't been checked by the store for over 2 weeks now. The new podcasts are there - you can fin

  • Mini Port on Mac Pro dosent work

    Hi there, Just get my new Mac Pro 12 core. I tried to install my 2 monitors that have already been tested on other computers. On is plugged into the DVI port and work just fine, the other one is plugged into one miniDV port and then into an HDMI cabl

  • I can't run Enterprise manager in my server

    Hi all i have aserious problem with oracle 10g Enterprise manager .i have install oracle 10 g and also i installed enterprise manager Grid Controller but i can't find this in start menu second i tried to run it from internet explore by writing http:\