Read lines until the line contains a special end-of-file marker. Eg, the old unix program 'mail' append all lines until a line consisting of a single '.' is read.
// insert this before reading the filename
StringBuilder content = new StringBuilder();
s = read.next();
while( !s.equals(".")) {
content.append(s);
content.append(String.format("%n"));
s = read.next();
}
The look at this: write a string into file (better answer than the other) and use that as an example of how to actually write the contents to the file, after it has been created.
p.s.
Pro-tip: I'm sure you have noticed that you have duplicated exactly the same line for checking if a filename is valid. A good programmer would notice this too and "extract" a method that does the logic in one place.
Example:
boolean isValidFilename( String s ) {
return !(y.contains(".") || y.contains(",") || y.contains("{") || y.contains("}") || y.contains("@")));
}
You may then replace the checks;
while (!isValidFilename( u )){
System.out.println("Your File-type name contains an incorrect character...etc");
}
This is good since you don't have to repeat tricky code, which means there are fewer places to do errors in. Btw, the negations (!) are there to avoid negative names (invalid=true) because you might end up with a double negation when using them (not invalid=true) and that may be a bit confusing.