Hey here is my code i have created its a simple file creation program as i have only been using java for the past 2 days. I'm only 13 so please be simple :)
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Filecreator
{
public static void main( String[] args )
{
Scanner read = new Scanner (System.in);
String y;
String u;
try {
System.out.println("Please enter the name of your file!");
y = read.next();
while (y.contains(".") || y.contains(",") || y.contains("{") || y.contains("}") || y.contains("@")){
System.out.println("Your Filename contains an incorrect character you may only use Number 0-9 And Letters A-Z");
System.out.println("Please Re-enter your file name");
y = read.next();
}
System.out.println("Please enter the file type name");
u = read.next();
while (u.contains(".") || u.contains(",") || u.contains("{") || u.contains("}") || u.contains("@") ){
System.out.println("Your File-type name contains an incorrect character you may only use Number 0-9 And Letters A-Z");
System.out.println("Please Re-enter your file-type name");
u = read.next();
}
File file = new File( y + "." + u );
if (file.createNewFile()){
System.out.println("File is created!");
System.out.println("The name of the file you have created is called " + y + file);
}else{
System.out.println("File already exists.");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
If you run it on a program such as Eclipse you will see the output. But i want to be able to edit the [file's] contents before i finally choose the name and the file type and then save it. Is there anyway i can do this? Thanks - George