Hi all
How can i open a .txt file through menu item.Plz help me
Printable View
Hi all
How can i open a .txt file through menu item.Plz help me
Add a listener to the menu item and when the item is selected, the listener will be called and there you can open the file.
You can probably find all you want by using a search.
Look that the API doc for the type of menu item you are using, find the addListener methods that are defined for that class and do a search for those methods. That could find you examples of how to use them.
Same for the other parts of the problem.
You can use the File class to open a file and the scanner class to read it. It isn't that difficult to write a simple text reader.
Java Learner,
These other two posters are heavily experienced, I did not try to get this to compile: They can help you with this:
Code:import java.io.File;//
import java.io.PrintWriter://
public class FileDemo
{
public static void main(String[] args)
{
// Simple
for(int i= 0;i < args.length;i++)
{
File nextFile = new File(args[i]);
if(nextFile.exists())
{
;// That file already exists.
}
else
{
PrintWriter printWrite
=
new PrintWriter(nextFile);
}
}
}