Trouble with File().mkdir()

I don't know if this is the best forum for the question, if not, I'll be happy to repost it elsewhere.
Anyway, I'm trying to learn how to create a directory using Java. So I go to lookup various examples and and all of them seem to call File().mkdir(). That's great, except I can't get any code with that command to compile. The code I am trying to compile at the moment is:
import java.io.*;
import java.io.File.*;
class File
   public static void main(String args[])
      try
         String strDirectory ="test";
         // Create one directory
         boolean success = (new File(strDirectory).mkdir());
         if (success)
            System.out.println("Directory: " + strDirectory + " created");
      catch (Exception e)
         //Catch exception if any
         System.err.println("Error: " + e.getMessage());
}I keep getting the error:
File.java:13: cannot find symbol
symbol : constructor File(java.lang.String)
location: class File
boolean success = (new File(strDirectory).mkdir());
Any ideas?

To avoid ambiguity with your class which you named File you need to supply the namespace:
boolean success = (new java.io.File(strDirectory).mkdir());Also, for the imports:
// Gives you everything under java.io including File
import java.io.*;
// Gives you just File, not needed with above import
import java.io.File; // .* is not needed if it is the actually class and not a package

Similar Messages

  • Trouble with File Sharing

    Hi,
    In April I upgraded my old Core Duo MBP to a shiny new Core i7 MBP. From the get go I have had problems on and off with Apple File Sharing and Screen Sharing over my network. I have a Mac Mini hooked into my entertainment center used as a HTPC and I generally had controlled it via the laptop screen sharing over the network.
    When I received the i7 I began to notice issues, the machines would randomly not connect. The Mini would still show up in the sidebar of finder windows, but would hang on "Connecting..." for a minute or so and then report "Connection Failed." Attempting to share the screen would give the same result, telling me to check both my network connection as well as the sharing settings on the Mini. I know the Mini is configured correctly, as I can have my old Core Duo laptop right next to the i7 and it will connect perfectly.
    system.log reports this if that helps"
    er.session
    Jul 13 16:41:49 Sven /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder[109]: SharePointBrowser::handleOpenCallBack returned 64
    ("Sven" being the name of the i7 laptop)
    I have also noticed that nether the Mini nor the Core Duo laptop can connect back to the i7, even though I have verified the settings in the i7 as having both File Sharing and Screen sharing on. Rebooting the i7 does not seem to help, however seemingly at random it will start working again at a later time. Sometimes it works flawlessly and others it does not. Earlier today I was having no problem watching a DVD on the Mini, I left and closed the i7's lid putting it to sleep, to come back later to it being unable to connect.
    Any help is greatly appreciated.
    (Afterthought: I am still using 10.6.3 on the laptops because I also use them with Steam for gaming and according to Steam they at this time do not recommend upgrading due to some problem with the graphics cards and 10.6.4?)

    Update: It also appears that the computer no longer wants to recognize the printer that connects to my WiFi network either (I printed several pages just earlier today, now it keeps telling me there is a communication error with the printer). Internet still works fine, but it seems any form of communication with other devices via my home network is off limits.

  • Trouble with file paths

    Hi,
    I'm trying to read a XML file using:
    XMLDocBuilder.java
    public Document getXML(String filepath) throws SAXException, IOException, ParserConfigurationException
              File myFile = new File(filepath);          
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(false);
              DocumentBuilder docBuilder = dbf.newDocumentBuilder();
              Document myDoc = docBuilder.parse(myFile);
              return myDoc;
         }If I run it directly from Eclipse/Tomcat, it works fine, but if I try to run it from the browser I get the exception "java.io.FileNotFoundException: C:\Documents and Settings\daugusto\content.xml (The system couldn't find the specified file)". (The file isn't there, it's on D:\MyFiles\myProject\WebContent\content.xml)
    I've tried quite some ways now and still couldn't get this to work.
    How can I get it to work from a browser?

    The class receives the filepath argument from a JSP page, after the user submits a form.
    I'm trying to load the XML Document and return it to the JSP page so I can work with it's elements. Using the <input type="file"> component?
    You don't want to retrieve the file using the java.io library.
    The server normally doesn't have access to the client file system. The only exception is when you are a developer working on your local machine where the server and the client are one and the same. That is not the general case :-).
    Intead use a library like the apache commons file upload to read the binary data of the file uploaded.
    cheers,
    evnafets

  • Trouble with Files organizing into Folders.

    I am really frustrated with Itunes today. I am trying to reorganize my library from scratch. All of my music is saved to an external Hard Drive, from which I will be pulling music from and adding it back into my Itunes library. My problem is that I can't stand it when Itunes organizes my music into folders.
    Artists > Albums > Songs. I dont want this. I just want all of my tracks to be in one folder, organized by name. Now I when I go to preferences and under te advanced tab, the "Keep Itunes Media Folder Organized" box is UNCHECKED. And it is still organizing my songs into folders when I add my music to itunes.
    I am pulling my hair with frustration on this one and I dont know what to do... PLEASE HELP!

    I'm suddenly having this problem also. "Keep iTunes Media folder organized" and "Copy files to iTunes Media folder when adding to library" have NEVER been checked.
    On March 2, 2012, iTunes updated and now all the songs that were in my Singles folder were renamed and moved into individual Artist folders that never previously existed. I now have 1000s of Artist folders with a single song in each. I also now have 1000s of exclamation marks in front of the songs in my library because iTunes can't find the songs it moved!
    I've spent several days reversing what iTunes has done and I'm still not finished. I'm also concerned about the next iTunes update destroying my days and days of work by moving my music again.
    How do I prevent iTunes from renaming/moving my music files when I'm not allowing the program to do that in the first place?

  • Troubles with File sharing on Mac Mini Server

    Hi
    Experience crash behavior of 10.6 server on my Mac Mini with DataBox connected containing all kind of data, except the system software which is installed on the internal hard drive. All my shared volumes, about 10, generating more or less regular (about every 30 minutes) the server preferences to crash.
    The two entries in the console log are always to same for all shared volumes I have:
    19.02.10 00:07:18 Server Preferences53715 XSActionManager: Removing queued action (Zugriffsrechte lesen) due to coalescing (readSettingspath/Volumes/DataBox 2/Dumy)
    19.02.10 00:07:18 Server Preferences53715 The shared folder 'Dumy' has custom file system ACLs which cannot be displayed. Editing the permissions may replace any custom ACLs.
    Once a day, the console log shows for all services running on the server:
    19.02.10 05:37:17 Server Preferences53715 Error: The server 'Dumy.com' reported an error while processing a command of type: 'readSettings' in plug-in: 'servermgr_accounts'. Error: Error Domain=XSActionErrorDomain Code=408 UserInfo=0x107e2c650 "A network error occurred"
    Did anybody have a good idea how to overcome this and how to decode the "UserInfo=0x107e2c650"
    Thanks for taking care.
    Thomas

    If I understand your question correctly, is there a reason you've replaced the integrated MySQL within Mac OS X Server with a second MySQL database implementation? (That's almost inherently going to get tangled; you'll need to shut off the default implementation.)
    Or is this a Perl module you've loaded and that is now tipping over? If you haven't replaced MySQL here, then have you started MySQL and run some tests with the database itself? This to make sure MySQL is operational, and that the problem you're working on is in the Perl pieces and not in the MySQL layer?

  • Troublie with File Sharing and Other Activities between two Macs

    Here's my situation. I have two Macs... a MacBook Pro and a Mac Pro, both running OS X 10.5.7. They connect to the Internet wirelessly through an Apple Airport Extreme (N) Base Station. But I also have them connected to each other via Ethernet. AppleTalk is turned on, only on the Ethernet connection.
    My problem is that I want to curtail all computer-to-computer communications (file sharing, Airfoil speaker connections for playing iTunes, Chronosync file synchronization, etc.) so that they ONLY occur over the Ethernet connection.
    I have both computers setup so that "Ethernet" is first in the sort order for network connections. File Sharing is turned on on both computers.
    But... I can tell that, sometimes, the connection between the two computers is occurring over the WiFi instead of through the Ethernet (for instance, I disconnect from the WiFi on the Mac Pro and the music playing through AirFoil stops... or Chronosync can't connect to the laptop to perform a sync).
    Am I just up a creek? Or is there some way to ensure that the two computers only "see" each other over the Ethernet connection and not over the shared WiFi? I know that, with "N" speeds on the Airport Extreme (and with N-capable cards in both computers), the "speed" thing isn't that big of a deal. But when running a Chronosync synchronization where several GBs of shared files are being synched, it still puts a crimp in Internet browsing speeds, etc., if that data is going over the WiFi instead of the Ethernet.
    Thanks!

    Hi,
    I'm not certain of this but whilst you're waiting for a more informed response here goes. OSX uses something called the "default route" which prefers the one with internet access over the order of networks you set in preferences, therefore, the default route isn't necessarily the fastest route. Without editing configuration files or using hardware or software to hard code routing routines, you'll need to switch off Airport and hence the default route will become the network created automatically by your ethernet connected Macs. Apple Talk isn't necessary.
    This thread may be of interest to you:
    http://discussions.apple.com/thread.jspa?threadID=2039622&tstart=0

  • Having trouble with file location

    I just learned how to get the javac thing to work.
    now it is saying that file is not found.
    i even tried pathing to it. then when that didnt work i
    put it in the bin folder. still didnt work
    think you can help me.

    That's understandable, I just thought that it was the best word to use.
    I was trying to say that I could not direct the command line to the Java compiler.
    All that aside, I found the answer. I will certainly look other places before posting.
    It was my understanding that this was the best place to post my question.
    Thanks for sticking up for me. I really appreciate that.
    I see flaming others must be a part of Oracle's environment...
    weird, I though it was a very respectable organization, perhaps it is.
    Edited by: kybbles on May 10, 2010 1:11 PM
    Edited by: kybbles on May 10, 2010 1:13 PM
    Edited by: kybbles on May 10, 2010 1:21 PM
    Edited by: kybbles on May 10, 2010 1:22 PM

  • Trouble with File Out rendering

    When rendering File Out nodes, Shake sometimes are not overwriting the existing file (when rendering multiple times..)
    How can I get Shake to overwrite the existing File Out file?

    It has been my experience that if Shake encounters an error writing to the FileOut (say if FCP has the file open), you encounter NO error message. Shake will spend the time rendering but never write out the file. In general, just prior to rendering, I delete the output at the finder level...
    Patrick

  • Trouble with file deleting!

    Im trying to empty a directory that I filled just before by unzipping a file in it. Here is the code im using:
    public void emptyDir(File srcDir)
    String[] toRemove = srcDir.list();
    File temp;
    for (int y = 0; y < toRemove.length; y++)
    temp = new File(toRemove[y]);
    System.out.println("temp: " + temp.getName());
    if(temp.exists())
    if(temp.delete())
    System.out.println("deleted");
    else
    System.out.println("not deleted");
    here is the the result:
    temp: dummy.info
    deleted
    temp: test0
    temp: test1
    temp: test2
    temp: test3
    temp: test4
    temp: test5
    Why are some of the file listed by list() not deleted? like they do not exists.
    If you guys know a way to make sure that all the files in the directory are deleted, it really would be welcomed.
    W

    its fixed now, the file exists since they are listed by the srcFile.list() but the problem was the path sent by that command. In fact it was just the giving back the name of each of the file in the directory.
    I changed the code to fixe that:
    File[] toRemove = srcDir.listFiles();
    for (int y = 0; y < toRemove.length; y++)
    toRemove[y].delete();
    like that i dont have to check them since I know they exists because they have been listed.
    thanks anyway!
    W

  • Trouble with File erasure.

          File file = new File(filename);
          file.createNewFile();
          in = new BufferedReader(new FileReader(file));
          out = new BufferedWriter(new FileWriter(file));When I call this code, the existing contents of the file in question are completely erased. Can I avoid this in some sensible way? Thanks.

    out = new BufferedWriter(new FileWriter(file, true));Michael Bishop

  • I have been having a lot of trouble with the latest itunes update and my ipod classic 80Gb i.e. being unable to sync songs, but now i have no files at all on my ipod, it is completely blank when i view it from my computer. I need help, please, anybody.

    As it says above, i have been having a lot f trouble with my ipod classic and the latest itunes update, i was unable to sync songs or anything to it and have tried every conceivable 'fix' i could find. i have run an itunes diagnostic and the results are posted below. a major problem is that when i try and view my ipod through my computer it displays nothing at all on the ipod, no files or anything, this may be the problem but i have no idea how it has happened or how i could resolve it.
    This ipod holds huge sentimental value and i am loathe to buy a new one! If anybody can help it is greatly appreciated, than kyou in advanced.
    Microsoft Windows 7 x64 Home Premium Edition Service Pack 1 (Build 7601)
    ASUSTeK Computer Inc. K50IJ
    iTunes 11.1.5.5
    QuickTime not available
    FairPlay 2.5.16
    Apple Application Support 3.0.1
    iPod Updater Library 11.1f5
    CD Driver 2.2.3.0
    CD Driver DLL 2.1.3.1
    Apple Mobile Device 7.1.1.3
    Apple Mobile Device Driver 1.64.0.0
    Bonjour 3.0.0.10 (333.10)
    Gracenote SDK 1.9.6.502
    Gracenote MusicID 1.9.6.115
    Gracenote Submit 1.9.6.143
    Gracenote DSP 1.9.6.45
    iTunes Serial Number 0038B8600B98D1E0
    Current user is not an administrator.
    The current local date and time is 2014-03-21 16:52:39.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is not supported.
    Core Media is supported.
    Video Display Information
    Intel Corporation, Mobile Intel(R) 4 Series Express Chipset Family
    Intel Corporation, Mobile Intel(R) 4 Series Express Chipset Family
    **** External Plug-ins Information ****
    No external plug-ins installed.
    Genius ID: 2fd81a1f13cf3ff25a8b4f0e8e725116
    **** Device Connectivity Tests ****
    iPodService 11.1.5.5 (x64) is currently running.
    iTunesHelper 11.1.5.5 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    Universal Serial Bus Controllers:
    Intel(R) ICH9 Family USB Universal Host Controller - 2934.  Device is working properly.
    Intel(R) ICH9 Family USB Universal Host Controller - 2935.  Device is working properly.
    Intel(R) ICH9 Family USB Universal Host Controller - 2936.  Device is working properly.
    Intel(R) ICH9 Family USB Universal Host Controller - 2937.  Device is working properly.
    Intel(R) ICH9 Family USB Universal Host Controller - 2938.  Device is working properly.
    Intel(R) ICH9 Family USB Universal Host Controller - 2939.  Device is working properly.
    Intel(R) ICH9 Family USB2 Enhanced Host Controller - 293A.  Device is working properly.
    Intel(R) ICH9 Family USB2 Enhanced Host Controller - 293C.  Device is working properly.
    No FireWire (IEEE 1394) Host Controller found.

    Here is what worked for me:
      My usb hub, being usb2, was too fast. I moved the wire to a usb port directory on my pc. That is a usb1 port which is slow enough to run your snyc.

  • I'm using the latest photoshop cc 2014 with most updated camera raw... i am having A LOT/REPEATED trouble getting files to "synch" with corrections, no matter what i options i select (i.e. "everything")... WTH is wrong with me/my computer/adobe?! help. fa

    I'm using the latest photoshop cc 2014 with most updated camera raw... i am having A LOT/REPEATED trouble getting files to "synch" with corrections, no matter what i options i select (i.e. "everything")... WTH is wrong with me/my computer/adobe?! help. fast. please

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Troubles with xmp files not loading...

    I'm having troubles with xmp files not loading with images but are present in the image folders. does anyone know why this is happening and if there is a way to fix this. Also when trying to load the xmp individually they are grayed out and unable to load. I have tried this on different machines (Macs) and still no luck. Any help would be greatly appreciated in this issue.

    > The information contained in the XMP file is stored in the DNG file so there is no need for a separate file.
    Aww, yuck!! That's a real drag...
    When editing lots of files (yesterday's shoot produced 8GB) I back everything up to off-line storage and then, after doing all my edits and crops in ACR, I only have to copy over the small XMP files which takes no time at all.
    So if I re-edit the DNG with ACR I have to re-copy ALL the files again to the off-line storage.
    I used to sometimes even save 2 versions of the xmp files when I needed 2 different crops of the same images, such as doing a wide screen 'cinema' crop for a corporate client's Intranet presentation of their event, as well as more standard crops to be used for their newsletters.
    Guess I won't be using DNG any more..
    Thanks for the help Kees :-)
    Russell

  • HT1926 Started having trouble with iTunes so I uninstalled everything and tried to reinstall but it says ' iTunes cannot run because some of its required files are missing. Please reinstall iTunes.'  Well, I've uninstalled and reinstalled 5 times.  Now wh

    Started having trouble with iTunes so I uninstalled everything and tried to reinstall but it says ' iTunes cannot run because some of its required files are missing. Please reinstall iTunes.'  Well, I've uninstalled and reinstalled 5 times.  Now what?

    I figured it out.  A week ago I had downloaded a screensaver from a website I trusted and that's when my problems started. I uninstalled it but that didn't help.  So, I reinstalled it then used an uninstall softtware app that cleanns more than the control panel does. Then I used a computer cleaner to be sure everything was wiped clean.  And it worked.  I downloded iTunes for the 7th time in 2 days and finally it worked!  And I lost nothing from my account.
    Maybe this info will help others.

  • DW MX trouble with loading PDF files

    I'm using Dreamweaver MX on an XP Pro machine and have
    trouble loading pdf documents to my web pages. It cooperates
    intermittently. I'm using a virtual pdf printer to convert word
    documents to pdf, then saving them to my website folder, selecting
    the linking text on my page in DW, using the link box to select my
    pdf document, then saving the page and putting files in both the
    local and remote views.
    This method has worked for me before, and now it's not. Does
    anyone know of a reason for this? The documents are saved
    correctly, as I can get them to open as pdf outside of dreamweaver
    and my webpage...when I click on the link I created online I get
    "page not found."
    Thanks for any help!

    I am having the same trouble with Dreamweaver MX 2004 on
    Mac-OSX since I switched from MacOs9. I still have no solution .
    When I want to export a .pdf file I get a message saying <ftp
    error>.
    I never had problems on Mac Os 9 and it started when using
    the first version of Mac Os X. I am presently using mac Os 10.4.10
    and I am still unable to transfer .pdf files, no matter whether I
    use acrobat or the Mac system to produce the.pdf file.
    When I try the page on my computer the link to the.pdf file
    functions allright, but not on the server as the file cannot be
    transfered to it by the software.
    Does someone know how to solve this ?
    Q]
    Originally posted by:
    milflib
    I'm using Dreamweaver MX on an XP Pro machine and have
    trouble loading pdf documents to my web pages. It cooperates
    intermittently. I'm using a virtual pdf printer to convert word
    documents to pdf, then saving them to my website folder, selecting
    the linking text on my page in DW, using the link box to select my
    pdf document, then saving the page and putting files in both the
    local and remote views.
    This method has worked for me before, and now it's not. Does
    anyone know of a reason for this? The documents are saved
    correctly, as I can get them to open as pdf outside of dreamweaver
    and my webpage...when I click on the link I created online I get
    "page not found."
    Thanks for any help!

Maybe you are looking for