This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Edit File Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Edit File" Watch "Edit File" New topic
Author

Edit File

Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 102

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
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

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


Never ascribe to malice that which can be adequately explained by stupidity.
Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 102

Ok, anyway I made it:

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32833
    
    4
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: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Edit File
 
Similar Threads
Cyberschool Assignment
Android HelloWorld Error
My GUI's catch block won't compile
JMenu text color
How to remove/disable buttons on submit