File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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 sourcefile.java.
How to give relative path, instead of full path name?
Thank you in advance
Garandi
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

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 java.io 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.

java.io.File


[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writting a String to a file