in my project, I am opening text files, and im doing some changes to the files, and I want to save the file after im chaning it, like Save As with a location browse. Can I do it somehow?
Thanks for the help!
in my project, I am opening text files, and im doing some changes to the files, and I want to save the file after im chaning it, like Save As with a location browse. Can I do it somehow?
Thanks for the help!
Here is a link that should help you: Binary streams
Or you can maybe try this: Reading/writing text files
A little search over the internet will help. Here;s a basic program that will read from one file and write to other. You can modify as per your requirement.
import java.io.*;
public class CopyFile {
public static void main(String args[]) throws IOException
{
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("input.txt");
out = new FileOutputStream("output.txt");
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
}finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
Some more tutorials here:
You should offer some code. However, yes by Using e.g. FileWriter you just open your File with FileWriter(File file, boolean append=true)
and call close() when your done. Saving is automatic so to say.