SmithUK Posted January 31, 2009 Share Posted January 31, 2009 package personstorage;import java.util.*; import java.io.*; /** * * @author edmundsWP */ public class enterdetails { static BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException{ // TODO code application logic here String name = null; String surname = null; System.out.println("Enter name please..."); name = userInput.readLine(); System.out.println("Enter surname please..."); surname = userInput.readLine(); System.out.println("Thank you " + name + ' ' + surname); FileWriter file = new FileWriter( surname + ".txt"); BufferedWriter buffer = new BufferedWriter( file ); buffer.write(name); buffer.newLine(); buffer.write(surname); buffer.close(); } } bear with me im new to programming, this is working but it stores the file in the default program folder... how might i go about using a folder named "contacts" or something within the program folder? Link to comment Share on other sites More sharing options...
0 ekw Posted February 1, 2009 Share Posted February 1, 2009 bear with me im new to programming, this is working but it stores the file in the default program folder...how might i go about using a folder named "contacts" or something within the program folder? "blah" -> local directory "../blah" -> up one level "/contacts/blah"-> in contacts Link to comment Share on other sites More sharing options...
0 SmithUK Posted February 1, 2009 Author Share Posted February 1, 2009 thanks mate :) Link to comment Share on other sites More sharing options...
0 SmithUK Posted February 27, 2009 Author Share Posted February 27, 2009 bump, i cant get it working, any more suggestions? Link to comment Share on other sites More sharing options...
0 Tech God Posted February 27, 2009 Share Posted February 27, 2009 "blah" -> local directory"../blah" -> up one level "/contacts/blah"-> in contacts if he was on linux that would not work. /contacts/blah would start at the root of the directory hierarchy. If it is within the program folder, contacts/blah/ should work. Link to comment Share on other sites More sharing options...
0 SmithUK Posted February 28, 2009 Author Share Posted February 28, 2009 any chance of a small example?, i dont quite know how i would put that into the code example above windows xp btw Link to comment Share on other sites More sharing options...
Question
SmithUK
bear with me im new to programming, this is working but it stores the file in the default program folder...
how might i go about using a folder named "contacts" or something within the program folder?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts