We're learning file input and output in my programming class right now, but I have a Macbook Pro. I understand how to do it and I can do it on Windows but I'm having trouble finding out how to do it exactly for a Mac. I just can't seem to figure out what to put in the quotes for the 'File Fred = new File(' '); What do I need to put in the quotes to have it work? I have the file in the HDD named 'David'.
Active4 years, 10 months ago
Mac 101: Activate the Onscreen Keyboard in OS X. By Jenny Kortina Sep 24, 2008 - 5:00 AM CST. This is a little window with modifier keys that stick once or lock down by double-clicking. Combine this with the regular onscreen keyboard and you have a mouse-only solution for all your text input needs. Why Apple failed to include sticky keys. The Input Method Kit, introduced in OS X v10.5, provides a streamlined programming interface that lets you develop input methods with far less code than older Mac programming interfaces. It is fully integrated with the Text Services Manager.
Download Mac Os On Windows
MaryMary
![]() 5 Answers
On Mac OS, you use '/' (forward slash) and not ' (backward slash) to separate files in a path. Hard drives are located under '/Volumes'. So your file is probably /Volumes/David/mytext.txt .
Spike GronimSpike Gronim
Don't use '/' or ' at all -- use System.getProperty('file.separator'). This will give you the correct character on the current OS. There are system properties that will help you write good cross-platform code. Check out System.getProperties() in the javadocs.
For example, to create 'file.txt' in your home directory:
File myFile = new File(System.getProperty('user.home'), 'file.txt');
That will work on OS X, Windows, and Linux.
Jeremy BrooksJeremy Brooks
new File('/'); is your root in the MacOS filesystem.
Just open a Terminal, cd to / and things will be revealed to you.
Jochen BedersdorferJochen Bedersdorfer
You won't use the same type of file path string you would on Windows. AFAIK your Mac should treat file paths the same as other *nix operating systems, with the 'top' of the file system being
/ rather than C: .
Mac Os Develop Enable Text Input For Windows 10
You can also address files as relative paths, rather than absolute paths. If you run your Java program from some directory Tom GTom G
./program , with your text file in ./program/file.txt , then your argument is simply new File('file.txt');
Mac Os Developer Enable Text Input For Windows 7![]()
9,55522 gold badges3333 silver badges5151 bronze badges
Try just dragging your file from your desktop, to a terminal page. This will give you the exact path you need to type into you Java program. Also use text edit's
format Make Plain Text to make sure it is in the correct form to be read by Java.
Taylor AttixTaylor Attix
Not the answer you're looking for? Browse other questions tagged javamacosfile-io or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |