Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes I/O and Streams and the fly likes Writting a String to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Writting a String to a file" Watch "Writting a String to a file" New topic

Writting a String to a file

Garandi Garandi
Ranch Hand

Joined: Jan 07, 2003
Posts: 192
I have a String to write it to a file.
I have the following code.

myFile is in the same dir as the
How to give relative path, instead of full path name?
Thank you in advance
Joe Ess

Joined: Oct 29, 2001
Posts: 9138

Give the File constructor the relative path (which the documentation referrs to as a pathname):

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Writting a String to a file
jQuery in Action, 3rd edition