I am making a Java application and I can't make it save multiple text files. The program must save a different file everytime the save button is pressed. Can it be done?
I thank you in advance

Recommended Answers

All 3 Replies

yup, can be done easily.

Here is some partial code to help out a little more...

private String baseFileName = "junk";
private int i = 0;
public void save()
       String tempFileName = baseFileName + (i++) + ".txt";
       // Insert Stream Declaration Stuff       
       // Insert Code to Save File
       // Close Streams

Hi everyone,

Simply you can put you text in a jtextarea and use the write api for the jtextarea to save the text but if you are using a jtextpane then you can use the
object stream or rtf kit to read and write. Check out their invidual api's for details.

Try to yahoo for them as there are a lot of different of stream format of doing things.

Richard West

ps. Don't foget to answer the thread on the bottom of my signature

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.