Results 1 to 1 of 1
-
Adding file contents to Choice component
The applet presented below reads a file and adds its contents to Choice component.
Java Code:import java.applet.*; import java.awt.*; import java.net.*; import java.io.*; public class ReadDataInChoice extends Applet { Choice myChoice; public void init() { myChoice = new java.awt.Choice(); add(myChoice); readFile("dataforchoice.txt"); } public void readFile(String f) { try { String anItem = ""; URL source = new URL(getCodeBase(), f); BufferedReader in = new BufferedReader(new InputStreamReader(source.openStream())); while(null != (anItem = in.readLine())) { myChoice.add(anItem); } in.close(); } catch(Exception e) { e.printStackTrace(); } } }
Similar Threads
-
Viewing contents of zip file
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 05:16 PM -
Concatenation file contents
By Java Tip in forum Java TipReplies: 1Last Post: 02-07-2008, 01:29 PM -
Reading file contents (BufferedReader)
By Java Tip in forum Java TipReplies: 0Last Post: 02-07-2008, 09:00 AM -
Viewing contents of JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 12-21-2007, 03:12 PM -
viewing the contents of a text file in JTextArea
By warship in forum New To JavaReplies: 0Last Post: 07-17-2007, 02:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks