Computer Science Canada is there a way to find out ... |
Author: | Genisis [ Thu Jun 15, 2006 8:01 am ] |
Post subject: | is there a way to find out ... |
is there a way to find out if there isnt a file by a name and if there isnt create a file by that name and if there is read from it? for example find the file Matts Numbers if there isnt that file create the file Matts Numbers if there is then Read that file |
Author: | HellblazerX [ Thu Jun 15, 2006 10:05 am ] |
Post subject: | |
What's the point of making a new file, and then just reading from it? It's not going to contain anything, and if you do add something, you have to have stored the values into your program, so what's the point of reading data you already have? And to answer your question, if you use BufferedWriter to write to a file, and the file is non existant, Java will automatically make the file for you. |
Author: | Omnipotence [ Sat Jun 17, 2006 10:44 am ] |
Post subject: | |
HellblazerX wrote: What's the point of making a new file, and then just reading from it? It's not going to contain anything, and if you do add something, you have to have stored the values into your program, so what's the point of reading data you already have?
Well no, he never said anything about READING from the new file, it could be that he makes the new file so that he can save stuff in it, maybe something to do with user input and read it for when the program is run again |
Author: | wtd [ Sat Jun 17, 2006 11:23 am ] |
Post subject: | |
Dealing with files? Java's File class docs seem the likely place to look for info. http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html |