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

Edit File

Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

Hello, I made little Swing program, I have also one button, now im wondering how to create this kind of function:

After Presing X button it should automaticaly open Hosts file, edit it, add some lines, and save.

Would be great if someone can help me, thanks in advice.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

what do you mean by "edit it' and "add some lines"?

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

Ok, anyway I made it:

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46367
Why are you using StringTokenizer, which is a legacy class?
What is supposed to happen and what goes wrong? Please look at this FAQ.
Why are you doing anything to a file in system32?
Why have you written an empty catch block?
I agree. Here's the link:
subject: Edit File
It's not a secret anymore!