Home Tutorialhelp Comment Using String.split for multiple values from a sing

 
 

Comment

Laurencd
Using String.split for multiple values from a sing,
September 12, 2010 at 4:10 PM

Hi
I started looking at java applet programming and am stuck.

I would like to know what i need to do to get "product" values listed on new lines. This is my code so far. (html in comments below java code)

<code>
import java.awt.*; //graphics
import java.applet.*;

public class animation extends Applet implements Runnable {

String company;
String product;
String[] multiple;
String delimiter = ":";
Font myFont;
Font notherFont;
Color textColor;
Color bgColor;
Color borderColor;
int Ypos = 20;
int Xpos = 100;

Thread runner;


public void start() {
if(runner == null) { // If thread runner is not running
runner = new Thread(this); //create new thread
runner.start();
}
}


public void stop() {
if(runner != null) { //If thread runner is running
runner = null; //stop runner

}

}
public void run() {
while(true) {
repaint();
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

public void init()
{
company = getParameter("company");
product = getParameter("product");
multiple = product.split(delimiter);

myFont = new Font("Arial",Font.BOLD,16);
notherFont = new Font("Arial", Font.ITALIC,12);

textColor = new Color(0,37,150);
bgColor = new Color(255,214,0);
borderColor = Color.blue;

setBackground(bgColor);

}

public void paint(Graphics g) {
g.setColor(bgColor);
g.drawRect(100,100,100,100);
g.fillRect(110,110,80,80);
g.setColor(borderColor);
g.drawRect(0, 0, 400 - 1, 100 - 1);
g.setColor(textColor);
// Shows what was in the HTML param code.
g.setFont(myFont);
g.drawString("company is:" + company,Ypos,Xpos);
g.setFont(notherFont);

for(int i = 0; i < multiple.length ; i++)

{
g.drawString("product name:" + multiple[i] + "\n",Ypos + 20,Xpos + 20);

}


Xpos--;
if(Xpos < -50)
Xpos = 100;
}
}

</code>

<code>
<APPLET codebase="classes" code="animation.class" width=400 height=100>

<param name="company" value="Big John's Used Mobiles">
<param id="product" name="product" value="Samsung:Apple:Erikson:why is this still on the same line">

</APPLET>

</code>

Thank you for any help

Laurence
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

validation of strings using java function
validation of strings using java function  hi all, i am uploading data from csv file to data base where i took student id as string of length 6 char of the form abc123 will you please give me a function to validate this field 

Java Beginners

strings
strings  1.Create a class named BuilderDemo. Use the string builder method to get the following output from string s4 Consider: String s4 = ‚??Java...) { String st="Java is an OO"; String str[]=st.split(""); String reversedSt 

Java Beginners

strings
strings  1.Create a class named BuilderDemo. Use the string builder method to get the following output from string s4 Consider: String s4 = ‚??Java...) { String st="Java is an OO"; String str[]=st.split(""); String reversedSt 

Java Beginners

strings
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2) check if the first begins with or ends with the second string   Here 

Java Beginners

strings
strings  java program for removing multiple spaces into single space 

Java Beginners

retrieve multiple columns values from multiple csv files in java
retrieve multiple columns values from multiple csv files in java  ...)///// here VendorID is corresponding to file1.csv i want to retrive data from... be specific in telling me through java only Any help will be much appreciated 

Struts Questions

how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java... is displaying.. i need code in java so that it takes multiple values... where i have to select multiple keyskills. but it is taking only one valuee.. i 

JSP Servlet Questions

how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...).second .java file for getting data from second table- package pack; public... for retrieving data fromm two tables : first table having fields: bookid,name 

JSP Servlet Questions

how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...).second .java file for getting data from second table- package pack; public... for retrieving data fromm two tables : first table having fields: bookid,name 

JSP Servlet Questions

how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ...).second .java file for getting data from second table- package pack; public... for retrieving data fromm two tables : first table having fields: bookid,name 

Java-Tutorials

Appending Strings - Java Tutorials
.style1 { text-align: center; } Appending Strings In java, the two main ways for appending string at the end are : First method is using... Comparison In first task, we will append string using += . And in second task 

Java Beginners

To get the String between two strings
To get the String between two strings  How to get string between two strings repeatedly using java?   Hi, Please tell me more about what do you want to achive. Thanks 

Java Beginners

How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere... = "Java"; protected String ivLastName = "Developer 

Java Beginners

How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere... = "Java"; protected String ivLastName = "Developer 

Java Beginners

Java create new array of strings.
Java create new array of strings.  Java create new array of strings...] name is an String type array can hold 7 values. You can also...(String[] args) { String name[] = { "mandy", "Rixi", "Ron 

Java Beginners

compare two strings in java
compare two strings in java  How to compare two strings in java... strings. By using the method compareTo, we have compared strings. If the strings...(String [] args){ String str="Roseindia"; String str1 

Java-Tutorials

Java Method Return Multiple Values
Java Method Return Multiple Values In this section we will learn about how a method can return multiple values in Java. This example explains you how... the steps required in to return multiple values in Java. In this example you will see 

Java Beginners

How to values from xml using java?
How to values from xml using java?  Hi All, I want to read value from following < Line> xml using java.. In < Line>,data is in format of key and value pair.. i want to read only values..could u plz help me 

Java Interview Questions

strings
strings  difference between the strings in java and c 

Java Tips and Examples

Concatenating two Strings in Java
to concatenate two strings in java. String are sequence of character which is used... that concatenate the two strings. String str1="hello"; String str2=" Java...;. You can also concat string using "+" operator in java which 

XML Questions

retrieve multiple attribute values
like is to retrieve both the attribute values of process:Output during execution time, store them so that it can be retrieved for later use using Java. Thanks...retrieve multiple attribute values  Hello All Am a beginner. Would 

XML Questions

retrieve multiple attribute values
using Java. Thanks in advance...XML retrieve multiple attribute values  Hello All Am a beginner...; What I would like is to retrieve both the attribute values of process 

XML Questions

retrieve multiple attribute values
like is to retrieve both the attribute values of process:Output during execution time, store them so that it can be retrieved for later use using Java. Thanks...retrieve multiple attribute values  Hello All Am a beginner. Would 

Free Magazine

Tips and Tricks
Tips and Tricks           Send data from database in PDF file as servlet response This example retrieves data from MySQL and sends response to the web browser 

Java Beginners

searching for strings in a file
searching for strings in a file  how can i search of a person and display the other details associated with the name using java gui window?  ...*; class Book{ int bookid; String title; String author; Book(int 

Java Beginners

strings in java
strings in java  please explain me the flow of this program..not able... static void main(String args[]) { String s=new String("a"); String s1 = "Hello"; System.out.println(s1.length()); String s2 = "Hello"; String s3 

Java-Tutorials

Java : String Concatenation
Java : String Concatenation This tutorial will teach you how to concatenate two strings using example. String concat() method :  Apart from replacing, removing splitting the string, Java also provides a method to concatenate 

Java-Tutorials

Java : String Concatenation
Java : String Concatenation This tutorial will teach you how to concatenate two strings using example. String concat() method :  Apart from replacing, removing splitting the string, Java also provides a method to concatenate 

JSP Servlet Questions

insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets 

Java Beginners

Strings
will contain strings which is separated by ",". From the main method invoke... a static method that returns the Sting array and takes a String as parameter. such as: The string passed will be a comma separated string e.g. this, is, a, String 

JSP-Tutorials

Uploading Multiple Files Using Jsp
Uploading Multiple Files Using Jsp  ... to understand how you can upload multiple files by using the Jsp. We should avoid... how the data is encoded. Whenever data is transmitted from one place 

Java Beginners

strings
in String object to display the mentioned output without using concat() method String s1 = ‚??Hello‚?? Output : hellO --- WOrldHellO For the above String s1, Display the same output using Chained methods 

Java Beginners

strings
in String object to display the mentioned output without using concat() method String s1 = ‚??Hello‚?? Output : hellO --- WOrldHellO For the above String s1, Display the same output using Chained methods 

Java Interview Questions

Strings
Strings  Hi Kindly send me the code for to finding the longest substring in a string like "abccbcabcdab" ----The answer should be "abcd". please send me the code using the logic compare elements with their ASCII value 

Swing AWT

multiple JComboBoxes using with JDBC
multiple JComboBoxes using with JDBC  how to use JComboBoxes...(){JFrame f = new JFrame("Frame in Java Swing");JLabel label1=new...;select * from user_details");jc1.addItem("Select");jc2.addItem(" 

Struts Questions

Retriving multiple values of checkboxes in struts
Retriving multiple values of checkboxes in struts  how to retrive multiple values of checkboxes of jsp in action class   JSP Retrieve checkbox values 1)checkbox.jsp: <html> <body> <form method="post 

Java Beginners

Retrieve values from database using views
Retrieve values from database using views  hi......... I have a huge... the columns which are required. As my front end is java swings i want to retrieve data from that created views and display on form . I am trying to do so but its 

JSP Servlet Questions

how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
or .txt) file and get the values from that file and store them into database...; //to get the content type information from JSP Request Header String... type is not equal to Null and as well as the passed data from mulitpart/form-data 

Java Beginners

Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able... to tell u.......... plz help????????? code in java swing 

JSP-Tutorials

Java Multiple Insert Query
the value after selecting the multiple values from the dropdown list...Java Multiple Insert Query In this example we will discuss about how to execute multiple insert query in Java. This example explains you about how 

JSP Servlet Questions

How to edit values in textboxes from database using jsp
How to edit values in textboxes from database using jsp  Hi RoseIndia... from database table using jsp, here is my code Please can anyone help me... language="java" import="java.sql.*"%> <%! String 

General

Find String Values of Cell Using POI
Find String Values of Cell Using POI   ... Values of Cell of  an excel sheet using POI3.0 API Event. The class ... FindStringCellsValues.java C:\POI3.0\exmples\execl>java FindStringCellsValues example.xls String 

Java Beginners

sorting an array of string with duplicate values - Java Beginners
sorting an array of string with duplicate values  I have a sort method which sorts an array of strings. But if there are duplicates in the array it would not sort properly 

Java Beginners

string
string  how do i extract words from strings in java???   Hi... ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String 

Programming Tutorials

@SessionAttributes multiple values
@SessionAttributes multiple values In this section we will see how you can use @sessionattributes to set multiple session values to it. While developing... example we are using @sessionattributes to put two session values formdata 

General

String Array
after they are created. A string buffers support multiple strings. Here... Java String Array      ... how to make use of string array. In the java programming tutorial string, which 

Java Beginners

string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html http 

General

Find Longest Word from the string using Java
Find Longest Word from the string using Java Here we are going to find the longest word from the string. For this, we have specified the string which... a method compare(String st1,String st2)  that will compare the two strings 

JSP Servlet Questions

How to carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using...). ----response.sendRedirect("index.jsp?uname="+username);---- But I want multiple values needs to be carried from my servlet to a JSP. How do I do 

Java Beginners

string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4 

Development process Questions

strings - Development process
strings  hi, I read a string from console.after that convert... { public static void main(String[] args) throws IOException { String string..."); string = reader.readLine(); double aDouble 

Java Beginners

Java dom from string
Java dom from string  Hi, How to create dom tree from string data? I am trying to search the example for java dom from string. Thanks   ... UpdateData { public static void main(String[] args) { String url="http 

JDBC

Mapping MySQL Data Types in Java
using MySQL data types and a application using Java data types. We need to provide.... For example, Java String don't precisely match any of the MySQL data CHAR type.... These data types could be mapped in Java to either String or char[]. But String 

Swing AWT

query on strings
query on strings  i want to convert JTextField data into string...=con.createStatement(); ResultSet rs=st.executeQuery("select * from data...(ActionEvent e){ String value=text.getText(); try 

Java Beginners

java program(strings) - Java Beginners
java program(strings)  Write a program in Java which accepts 2 strings as command line arguments. The program should do the following: i) print... in both the strings ii) replace every occurrence of ?a? or ?A? by @ iii) convert 

JSP Servlet Questions

how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create... = request.getParameter("id").toString(); System.out.println(id); String data 

Java Beginners

Grouping strings - Java Beginners
of strings. What I need to do is to group strings that are within a certain range... StringGroupDemo{ public static void main(String[] args) throws IOException...)); System.out.print("Enter text for finding groups of text: "); String 

Java Beginners

sorting an array of string with duplicate values - Java Beginners
String of Array  What is mean by string of array? And how one can add, delete the records from database in string format 

General

How to get Keys and Values from HashMap in Java?
How to get Keys and Values from HashMap in Java? Example program of iterating... and values from HashMap? This is the most asked questions in the Java... through keys and get the values from a HashMap object. The entrySet() method 

Java Beginners

Strings - Java Beginners
. eg: Obj o1=new Obj(); Obj o2=o1; But is case of Strings, how is it that two different object references are being created? String s1="Hello"; String 

JSP Servlet Questions

Passing Parameter Values to another jsp in Query Strings
Passing Parameter Values to another jsp in Query Strings  HI ALL, I m trying to pass a variable value to another JSP using query string... even though some values* stored in the variable loginid. Can any one suggest 

Programming Tutorials

Java read multiple files
Java read multiple files In this section you will learn how to read the data of multiple files. Here we have created four files that includes information.... We have to find the students according to particular school from all the files 

Core Java

Java String
Java String       In this section, you will learn about the java string. Java String is a set... the content of string. String is special-cased when doing data serialization 

PHP Tutorial

php Strings
This is a multiple line string using heredoc method. END; echo "<br/>... variable This is a multiple line string using heredoc method... php Strings       String 

JSP Servlet Questions

want to ask how to update data for runtime selected multiple checkboxes
want to ask how to update data for runtime selected multiple checkboxes  HI I have one problem I have fetched value from oracle database into grid... and entered the values in the textbox then it should get update in the database.I 

Java Interview Questions

STRINGS - Java Interview Questions
STRINGS  1.Why string objects are immutable? 2.why java is pass by value?  Hi Friend, 1) To save memory, java can refer two string references to the same underlying string object on the heap. So if you try to change 

Java Beginners

Java String
Java String  You are given two strings S1 and S2,Delete from S2 all those characters which occur in s1 also and create a clean S2 with the relevant characters deleted..write a pgm for this..pls send as soon as possible Thank you 

Java Beginners

STRINGS - Java Beginners
STRINGS  WRITE A JAVA PROGRAM TO REVERSE THE ORDER OF WORDS IN THE SENTENCE...EXAMPLE" " "ANT EATS APPLES"SHOULD BE RETURNED AS" "APPLES EATS ANT...*; public class ReverseWords{ public static void main(String[] args){ String str 

Java Beginners

Comparing strings - Java Beginners
) a substring appears in a string? The code I've written can get it once and after that cannot continue to the end of the string.  Hi friend, import... void main(String[] args) throws IOException{ System.out.println("String 

Java Beginners

strings - Java Beginners
strings  how can i write an example of string arrays with loop... which shows how to create an array of String and prints the array elements. Code ===== class StringArray { public static void main(String args 

Java-Tutorials

String Functions In Java
(String anotherString) : This method compares two strings using Unicode value... compareToIgnoreCase(String str) : This method compares two strings using Unicode...String Functions In Java In this section we will see various methods of String 

Ajax Questions

Values from servlet into dropdownlist in jsp page using ajax
Values from servlet into dropdownlist in jsp page using ajax  1) jsp...); } } } Im not able to get values retrived from...;%@ page language="java" contentType="text/html; charset=ISO-8859-1 

Java-Tutorials

How To Append String In Java
How To Append String In Java In this section we will read about how to append String in Java. Here we will see the solution of this question through a simple example. There are various ways to append String in Java. Below, we 

Java Tips and Examples

String Array In Java
String Array In Java       In this section, you will learn how to use string array in Java. Here, you will see how to declare a string array and the syntax for using in the program 

Java Beginners

Fetching the exact data from file using java
Fetching the exact data from file using java  **hi ... i am having one .lst file.. that file consists of instructions and opcodes.. now i want to fetch only the opcode from that file.. could u pls anyone guide me this using java 

Programming Tutorials

Introduction to Dojo and Tips
Introduction to Dojo and Tips         This tips is light towards people with some JavaScript... need to use some of the features found in dojo. In this tips, learn about 

JSP Servlet Questions

passing values - JSP-Servlet
No: this is my java page for insertion package CHB; import java.sql.*; public class Blogic { private String name; private String hallno; private String time; private String date; private String mobileno; DBConnection 

JavaScript Questions

question about mixing two strings
question about mixing two strings  using java script we need to ask two strig and combine them like.. str1= helo str2= worl combined string= hweolrol 

Java Beginners

strings in java(18 june ,2011)
strings in java(18 june ,2011)  please explain me the flow... Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello"; System.out.println(s1.length()); String s2 = "Hello 

Java Beginners

strings in java(18 june ,2011)
strings in java(18 june ,2011)  please explain me the flow... Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello"; System.out.println(s1.length()); String s2 = "Hello 

Struts Questions

sing validator framework work in struts
sing validator framework work in struts  How does client side validation using validator framework work in struts 

JSP Tutorials

String Length
String Length          In java, Strings are objects that belong to class... of the string by using the method length() of java.lang.String. The code 

JDBC Questions

JDBC and Aggregate values
JDBC and Aggregate values  How to get the aggregate value using JDBC? Like I am executing the statement "Select Max(ItemId) from Items", and I get only one row, only one column in return and I want to get that data using JDBC 

Java-Tutorials

Java : String Compare
Java : String Compare This tutorial demonstrate various way to compare two strings.  String Compare : In java, you can compare strings in many ways... the strings.  int compareTo( String anotherString ): This method compare two 

Java-Tutorials

Java : String Compare
Java : String Compare This tutorial demonstrate various way to compare two strings.  String Compare : In java, you can compare strings in many ways... the strings.  int compareTo( String anotherString ): This method compare two 

Java-Tutorials

Strings in Switch statement
Strings in Switch statement In this section, you will learn about strings in switch statements which is recently added feature in Java SE 7. Using JDK 7, you can pass string as expression in switch statement. The switch statement 

JDBC Questions

Data from multiple ResultSets?
Data from multiple ResultSets?  hello, How can I get data from multiple ResultSets?   Hi, You can iterate the ResultSet separately and get the required data. Thanks 

JSP Tutorials

Uploading Multiple Files Using Jsp
Uploading Multiple Files Using Jsp  ... to understand how you can upload multiple files by using the Jsp. We should avoid... how the data is encoded. Whenever data is transmitted from one place 

Java Beginners

Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file...") != null) { Open connection to the database; Read parameters from 

Hibernate Questions

Data fetch from multiple SQL tables - Hibernate
Data fetch from multiple SQL tables   I am in the process of writing... multiple tables using left and right outer joins. I need to convert this JDBC data... example of HQL fetching data from multiple tables would be a help. I have tried 

Java Beginners

get values from Excel to database
get values from Excel to database   hi i want to insert values from... that should go to database which exists. am using SQL Server management studio express 2005. how can i do with java code 

Programming Tutorials

Java Data Types
Java Data Types      ...' that holds a data as a numerical value '1'. The values contained by the variables... more primitive data types which are supported by Java language programming 

Java Beginners

Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file...") != null) { Open connection to the database; Read parameters from 

XML

JAXB Create XML File And Get Data From XML
using Java Object then we will read that XML data as Java Object again...JAXB Create XML File And Get Data From XML In this section we will read about how to create XML file and how to convert XML file's data to Java Object 

Java Beginners

How to insert multiple checkboxes into Msaccess database J2EE using prepared statement - Java Beginners
How to insert multiple checkboxes into Msaccess database J2EE using prepared...("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:user"); String..., StrRemarks) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; ps 

Java Beginners

Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java 

JSP Interview Questions

How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1 

General

Java String Examples
and then you will get the number of vowels from that String. Java...() method of String class in Java. String copyValueOf(char[]†data... Java String Examples       

Java Beginners

How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java 

Java Beginners

How to export data from html to excel sheet by using java
How to export data from html to excel sheet by using java   How to export data from html to excel sheet by using java 

Advertisements Advertisements
 

 

 

DMCA.com