File I/O in Mac OSX

Does anybody know how to specify a filename and its path in MacOS X? I'm trying to read a dictionary file into a data structure, but can't get the IO to work properly. My CS professor says my code is good, but he doesn't know how to specify the path either. I've tried the following.
/hansona/Desktop/Dictionary.txt
~/hansona/Desktop/Dictionary.txt
hansona/Desktop/Dictionary.txt
Dictionary.txt
/Dictinary.txt
/Desktop/Dictionary.txt
Desktop/Dictionary.txt
I've also tried all of these using \ instead of /
NONE of them work. If anyone could throw me a bone here I would appreciate it. Also, here is my code.
import java.util.*;
import java.io.*;
public class playThing {
public static void main(String args[]) throws IOException {
String filename;
int state=0;
while(state==0){
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a path: ");
filename=stdin.readLine();
try{
File filepath = new File(filename);
FileInputStream fStream = new FileInputStream(filename);
InputStreamReader tempRead = new InputStreamReader(fStream);
BufferedReader word = new BufferedReader(tempRead);
System.out.println(word.readLine());
state=1;
catch(IOException e){
System.out.println("Error in opening input file:\n"+e.toString());
state=0;

Here is an example
String filename1 = "\directory";
String filename2 = File.separator + "directory";Both of those strings are the same. However, filename2 should work under any OS (assuming that directory exsists). Such as Unix/Linux, which use "/" as a separator.
I hope that answers your question.

Similar Messages

  • How to make a image file from Pre installed Mac osx ? "PLEASE HELP :("?

    hey guys ..Thanks u for the time.
    So i have this eMac which has crashed and i have got may hands on another eMac.. and it works
    ... the only problem is.. I can take my eMac to the working eMac to do Target Mode or any thing...
    So Help me..
    My question is .. Is there a way to make a .DMG image file from pre installed mac osx OR
    Is there a way to may a recovery disc??

    You can use Carbon Copy Cloner to copy everything from the working eMac onto the non-working eMac while the working eMac is running. If your eMac will still do target mode into the working one, you can download the above software, select the booted drive as the source drive, and your eMac's drive as the target, however it is possible this will not work.
    When you say your eMac crashed, what exactly happened?  It is possible that the hard drive in your eMac failed or is failing, so in order to get it running again you would need to replace the hard drive.  On the eMac, this repair is somewhat involved, and you have to be very careful because it exposes the CRT, which has several areas which can be extremely dangerous to touch if not properly handled.  CRTs retain a great deal of voltage, even when unplugged, sometimes for weeks, and they can give you a nasty shock if you touch them in the wrong place.
    Also keep in mind that cloning from the working computer to the non-working computer will ERASE any data that you have stored on that eMac, so if you don't have it backed up anywhere, you may want to attempt that with target mode before proceeding.
    Good luck!

  • Importing wav. files into itunes on MAC OSX

    I have a question, hope someone has the answer.
    I am a new mac owner, new ipod owner too.
    I currently have 200-300 gigabytes of SHN and FLAC files on my PC (mostly grateful dead soundboard recordings).
    I am planning on converting these files to WAV. format with "artist", "album" (show date), and "song" ID tags.
    I then plan on copying these WAV. files to my imac or separate external hard drive formatted for MAC OSX.
    OK THE QUESTION (finally, no?),
    When WAV. files are imported into itunes are they automatically converted to the MP4 AAC format?
    I have looked in the itune PREFERENCES menu I go to ADVANCED and see that there is a control for switching file formats for importing CD'S but there is no mention of importing WAV. files.
    On another note it is too bad that Apple has not come up with a file conversion utility for itunes, where FLAC, SHN, and WAV. files could be converted to MP4AAC, Apple Losless, etc...
    I appreciate any answers to my question, and also comments regarding the general subject of audio file conversion on the MAC OSX.
    Thanks

    Hi,
    Firstly, I must point out that WAV doesn't support tagging, so there is no point in converting your compressed FLAC and SHN files to WAV before making the move over to a Mac.
    Rather, it would make more sense to use the free and excellent Max to convert all these files automatically to the format of your choice, such as Apple Lossless. You can even run multiple conversions simultaneously, so you could, say, convert your whole lot of files to Apple Lossless while at the same time convert the same lot to AAC for use on your iPod. The program is highly configurable, allowing you to specify destination directories and whether or not the output files are added directly to your iTunes library. Also, the tagging will be preserved when converting FLAC and SHN files to supported formats.

  • Corrupted 80% file Illustrator  CS3 with MAC OSX 10.5.4

    I dont succeed to open the greater part of our file CS2 and CS3 saved in local or in network.
    this is the error message:
    "impossible to read the file because plug-in it has not been able to interpret these file".
    original its in IT lenguage :"Impossibile leggere il file perché il plug-in non ha potuto interpretare questo file"
    i use Mac OSX 10.5.4 illustrator release 13.0.1 for manage font, Linotype FontExplorer X last release. its very hark to work in this situation :s...

    #1) Update to Illustrator 13.0.2
    #2) It's always been Adobe's stance that you should
    never save and open files across a network because corruption can happen. Work locally, then copy to the server.

  • File encoding issues with Mac OSX?

    I really love DreamWeaver and I think its the best editor our there, except for one thing - the file encoding!
    I tried setting the default encoding to UTF-8 under Preferences -> New Document, but that won't cut it.
    Dreamweaver always creates/saves new files as Western/ISO format, so I always have to open them up with another text editor and overwrite the file with UTF-8 format.
    Is there a fix to this or a extension to download?
    I'm using CS4 on Mac OSX Leopard.

    CS4 should automatically save files as UTF-8. It's the default setting. You shouldn't need to do anything special.
    One thing you could try is removing the Prefs file. On a Mac, it's located at <username>:Library:Preferences:Adobe Dreamweaver CS4 Prefs.

  • File Server For Both Mac OSX and Windows?

    Hello All,
    With HP discontinuing theier HP Server line, I've been browsing around for quite some time at a good box to use as a file server.  My windows Home server is about to die i feel, and most PC based servers seem just as pricey as me acquiring a Mac Pro Server with Two 1TB Hard Drives and using OSX Lison Server.
    However, before I take that plunge I was really wondering if anyone had had any success or stories that they can share about using a Lion Server with windows 7 PC's.
    I use a MAC, but everyone else here uses windows.  On my the home server box we bascially store all of our digital photographs, personal files and such as a backup.  Granted the Apple time machines and mac mini's can be used as the same but you loose the redundant hard drives and stability of comintuing to upgrade if you run out of space.
    So I'm hoping that its positive and pretty much flawless where the Mac Pro with Lion Server could just save and serve files galore without slow down or problems.  With my past mac experience that's usually not the case.  I just want to replace that box, have a new box that can store files off of the independent machiens with a here or there additional backup on it as needed.
    The other plus if I take this plunge is I have a Mac Pro box for greater functionality at home over my Macbook Pro!   So yeah, a little perk for me...
    Thanks in advance for any news you can help or offer me...  I know I'm probably asking something that a ton of others may have alredy asked and sorry for the duplication if thats the case

    Mac OS X Server can do all that.
    You can keep All the user accounts on the Server, or you can just use it for File Sharing. Does Windows SMB or Apple File System sharing without issue. Disk Utility can create Mirrored RAIDs right out of the box, that expensive RAID card is only needed for RAID 5.
    I run a Server at home like a School Server with ALL User files on the Server (you log on at any Mac and your files appear, because they are on the Server). User files are on a pair of Mirrored RAID drives, and I use Time Machine to automatically back up all the User Files on the Server once an hour. Gigabit Ethernet Switches provide "Hard Drive-like" file access.

  • Anybody have a resolution for PRIAMOS file download using a Mac OSX 10.6.8 and Adobe Reader XI?

    Does anyone have experience of the EU PRIAMOS file download system? I am experiencing difficulties in downloading files in Adobe Reader format ( I have set the default PDF reader to Adobe Reader).
    The PRIAMOS system can only communicate with Windows 32bit - Mozilla Firefox 2 and higher or......
    IE 6 or 7
    IE 7 or 8 (in compatibility mode)
    Supported PDF programmes are:
    Adobe Reader 8.1 or higher
    My Adobe Reader software is the latest version (Adobe Reader XI for Mac with latest update as at 10 Sept 2013)
    The PRIAMOS system does not officially support Mac computers, but PRIAMOS has been used successfully with OS X version 10.5.8 (Leopard) and Mozilla Firefox (2.5) (with built in PDF reader disabled and Adobe Reader enabled) and Adobe Reader 8.1
    Any help would be gratefully appreciated

    Oops, I hit return before I was finished!
    In short, does anyone have any ideas apart from those I've tried. One solution seems to be to go back to 10.6.4 - one of the other discussions seem to indicate that the probelm comes in with 10.6.8.
    Thanks!

  • DNG files showing no thumbnails mac osx 10.8.2

    when i convert raw photos from my olympus omd em5 into DNG's and export them to my external hard drive , i do not get any thumbnail previews , they can only be seen if i view the files through lightroom4 import , if however i export in other formats such as jpeg ,tiff etc.. i get a preview thumbnail . Iam using latest imac and running osx 10.8.2 , does anyone have a fix for this , many thanks in advance , as i really like the idea of DNG, but would love to have a thumbnail preview, if anyone has a soloution i would be most grateful

    Yup, as I said, luckily there's no problem for me with my NEFs either. And from memory (my iMac's in having its hard drive replaced so I can't check), I think it could read my old Fuji X100 RAFs without any issues too.
    The point is that the Apple raw engine can read some but not all DNG files.
    According to Apple, it's "most" if the camera produces native DNGs (which are as rare as rocking horse poop) or it can read some non-native DNG raw conversions, but for some others, only if you modify the DNG conversion by unchecking "Convert to Linear Image".
    It may turn out that some DNG conversions can't be read by the Apple raw engine at all, or maybe are readable but Finder can't extract the JPEG for a thumbnail. In either case you'll have to stick to using Bridge or Lightroom or some other browser/DAM software that can interpret DNGs if you can't see them in the Finder & want to.
    By the way, because it uses the Apple raw engine, shonky DNGs are blacked out in Aperture too (along with, I presume, iPhoto).

  • Files "greyed" out on Mac OSX

    The files in my "files" workspace tab and menu bar above it in Dreamweaver CC are greyed out (they don't show any colours), on my windows 7 computer they do have colour.
    I also have problems editing my CSS at times, it will blank out while I am editing, and Dreamweaver's been crashing.
    On an additional note I am using SVN as well on my local area network, is it possible that this could be the cause of my frustration, since it only started happening after setting up the SVN?
    Thank you, your help will really be appreciated!

    This is the iSync forum.
    .Mac Sync has it's own dedicated forum where you'll probably get more help.
    .Mac Sync

  • Silently Install a CMMAC file from SCCM onto Mac OSX

    Hello,
    is it possible to silently install a CMMAC program that has been generated using the CMAPPUTIL program on osx?
    if i deploy it, it always prompts for the user to install at a deadline or install now.
    Thanks

    Yes, I know this is an old post, but I’m trying to clean them up. Did you solve this problem, if so what was the solution?
    Since no one has answer this post, I recommend opening a support case with CSS as they can work with you to solve this problem.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • How to implement Mac OSX Finder color labels

    Is it possible to support color labels for files and folders in Mac OSX Finder in a custom connector? It would be nice to implement this in our connector as it's a common way for users to do some lightweight status workflow.
    If it's possible, a code sample would be really helpful.

    Is it possible to support color labels for files and folders in Mac OSX Finder in a custom connector? It would be nice to implement this in our connector as it's a common way for users to do some lightweight status workflow.
    If it's possible, a code sample would be really helpful.

  • 2 log-in screens after turning filevault 2 on in Mac OSX Lion?

    Hi -
    I turned file-vault on in Mac OSX Lion 10.7.3 and now I am presented with log-in screens 2 times whenever I reboot my mac. First log-in screen comes immediately, is a light gray screen with filevault-enabled users, so I enter my password there and after some time I am presented with a second normal log-in screen, dark gray with all users. After entering my password in this second login screen, I am able to use my mac.
    I am wondering if this 2 log-in screens is the normal behavior after turning on the filevault 2 on in Mac OSX Lion?

    Hi Linc -
    That is indeed what I am doing now, it is still decrypting. once it is done decrypting, I will start encryption again. I am not sure why the first screen is coming, just an FYI: I do not have firmware password set in my macbook as well.
    I will post back the status when I get around this, thanks for your response.

  • Simple way to play an MP3 on Mac OSX using AudioToolbox?

    Hi, I've been searching for some way to play an audio file (MP3 music) on Mac OSX similarly to how the AVAudioPlayer class for iOS works, but I can't find anything.
    I have found an apple sample code called PlayFile but it's thousands of lines of code and uses many custom classes.
    Is there any simpler way?
    thanks in advance..

    NSSound and QTKit are the easiest solutions for playing audio on Mac OS X. If you decide to use QTKit, I wrote an article on playing audio files with QTKit that may help you. You can read it at the following URL:
    http://www.meandmark.com/qtkitaudiopart1.html

  • I have an iMac 5.1 with Mac OSX 10.6.8 and 2 GB memory and an L2 cache of 4 GB.   lately I have been receiving error messages of " start up disk almost full; please delete files." is the start up disk the same thing as the hard drive?

    I have an iMac 5.1 with Mac OSX 10.6.8 and 2 GB memory and an L2 cache of 4 GB.   lately I have been receiving error messages of " start up disk almost full; please delete files." is the start up disk the same thing as the hard drive?  I opened the hard drive and from the column on the left of the menu I've selected "search for" and under that " all images" then "all documents"  I've deleted a few files from each. Are documents and images that I have deleted from here also deleted from the folders on my desktop?

    You should never, EVER let a conputer hard drive get completely full, EVER!
    With Macs and OS X, you shouldn't let the hard drive get below 15 GBs or less of free data space.
    If it does, it's time for some hard drive housecleaning.
    Follow some of my tips for cleaning out, deleting and archiving data from your Mac's internal hard drive.
    Have you emptied your iMac's Trash icon in the Dock?
    If you use iPhoto, iPhoto has its own trash that needs to be emptied, also.
    If you store images in other locations other than iPhoto, then you will have to weed through these to determine what to archive and what to delete.
    If you use Apple Mail app, Apple Mail also has its own trash area that needs to be emptied, too!
    Delete any old or no longer needed emails and/or archive to disc, flash drives or external hard drive, older emails you want to save.
    Delete any other mail in your Junk folders. Also, look through your Sent Mail to see if there is anything that can be deleted.
    Other things you can do to gain space.
    Once you have around 15 GBs regained, do a search, download and install OmniDisk Sweeper.
    This app will help you locate files that you can move/archive and/or delete from your system.
    STAY AWAY FROM DELETING ANY FILES FROM OS X SYSTEM FOLDER!
    Look through your Documents folder and delete any type of old useless type files like "Read Me" type files.
    Again, archive to disc, flash drives, ext. hard drives or delete any old documents you no longer use or immediately need.
    Look in your Applications folder, if you have applications you haven't used in a long time, if the app doesn't have a dedicated uninstaller, then you can simply drag it into the OS X Trash icon. IF the application has an uninstaller app, then use it to completely delete the app from your Mac.
    Download an app called OnyX for your version of OS X.
    When you install and launch it, let it do its initial automatic tests, then go to the cleaning and maintenance tabs and run the maintenance tabs that let OnyX clean out all web browser cache files, web browser histories, system cache files, delete old error log files.
    Typically, iTunes and iPhoto libraries are the biggest users of HD space.
    move these files/data off of your internal drive to the external hard drive and deleted off of the internal hard drive.
    If you have any other large folders of personal data or projects, these should be archived or moved, also, to the optical discs, flash drives or external hard drive and then either archived to disc and/or deleted off your internal hard drive.
    Good Luck!

  • I am running Mac OSx Lion 10.7.2. My problem is I can't search on an external network server for a file with the finder toolbar anymore. Nothing shows up and it will not search. I was able to in snow-leopard and am no longer able to w. Lion. Suggestions?

    I am running Mac OSx Lion 10.7.2.
    My issue is that I am not able to run a search in the finder toolabar on a network server. No files show up nor does it search on the server anymore. I was able to run the search in snow-leopard and am no longer able to do so with Lion. Is there a preference I can change or some kind of app or program I can download that will help me with this issue? This is extremely problematic for me as I am searching for files all day everyday. Thank you!

    Hello,
    It isn't the fw in Network you want o use or look at, that's for something completely different.
    My first suspect is the Power Adapter on the LaCie has gone.
    At the Apple Icon at top left>About this Mac, then click on More Info, then click on Hardware>Firewire, what is listed there?
    Reset the Firewire bus
    If your Firewire or USB isn't recognizing any device.  A solution which has worked for some whose hard drive became invisible in 10.4 was simply to follow these four steps to reset the Firewire/USB bus:
    1. Shut the machine down.
    2. UNPLUG the power lead to the computer and any firewire/USB drive or devices.
    3. leave it for 10 minutes.
    4. Connect back up and reboot.
    http://www.macmaps.com/firewirebug2.html

Maybe you are looking for

  • Unsupported file type (.mov)

    I am using Adobe After Effects CS4 (9...) I am trying to create Andrew Krammer's ,,crumble" effect (http://www.videocopilot.net/tutorial/procedural_crumble/) If you skip at 23:44 you will see that he is adding an imported .mov file. Everytime i try t

  • Photoshop CS6 sign in required not working

    the username/password is correct. it just will not proceed....

  • My iPhone 3GS is making multiple photo folders, not good

    I've been taking pictures and screen shots and they get put into about different folders randomly. Normally when I hook my iphone up to the computer, it will only show the "DCIM" folder, then "100APPLE" sub folder. Well now it is showing 100Apple thr

  • Bright blue flashes over menu screens

    I've just finished my first two projects in iDVD, and both have the same problem - the whole screen flashes bright blue on and off over the menus, on both DVD players and computers It's completely unwatchable. But the movies themselves are fine! The

  • Flash Object has no Publisher or Version in IE11 in Windows 8.1

    Hello, I have been trying to get flash player to work, and have tried several avenues in Windows 8.1. I have tried enabling Shockwave Flash, tried disabling ActiveX Filtering, re-register the flash.ocx file, resetting IE11,  and disabling/re-enabling