File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes saving text file as html file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "saving text file as html file" Watch "saving text file as html file" New topic

saving text file as html file

tanmay durgule

Joined: Aug 03, 2012
Posts: 1

I want to save selected text file as html file in target directory
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Welcome to the Ranch!

There are several things I don't understand there. First of all, what do you mean by "saving" a file? In many cases that means writing data from the application into a selected file; I can't tell if that's what you intended. There's no automatic way in Swing to do that, you have to write the code yourself which outputs the data.

Second, what do you mean by saving it "as HTML file"? A file isn't an HTML file unless it's formatted HTML data, starting with the <html> tag and so on. You can't take any old data and have it magically converted into an HTML file, if it wasn't HTML to start with then you have to do something to make it into HTML.

And third, what's that about a "target directory"? If you want the chooser to start by asking the user to select a file in a particular directory, then you'd use its setCurrentDirectory method to tell it what that directory is.
I agree. Here's the link:
subject: saving text file as html file
It's not a secret anymore!