No, that won’t work. And I could tell that without reading any of the code, except that I saw a \n character, which you shouldn’t use. Look
here to find out what to use instead.
You are going about the problem quite wrongly. What
you should do is to create a little application which uses the file chooser, and get that working. You can find more examples of how file choosers work
here. Go through that and learn how to use a chooser to open a file. I cannot remember whether you can use a chooser to create a file, maybe you can’t. But you can find that by reading the link I showed you and the
documentation. Note that many methods in the file chooser class require an argument for the Component the dialogue appears over. If you don’t have such a component, you can pass
null and the dialogue will appear in the centre of the screen. As I said, create a method which finds a File and returns it.
Then use a System.out to verify you have got the file:
System.out.println(f);
Do not try finding a file and writing it in the same method. Create a method which finds the file, and another method which writes to it. You are wrong to put that sort of code into the class’ constructor.
When you have those methods working, you can create a utility class, and put those methods into that class for use in future.
search my posts in this forum and “
Java in General” for “utility class”, and you should find some hints.