Results 1 to 3 of 3
- 10-08-2009, 06:57 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 40
- Rep Power
- 0
using the value taken from jsp page
import java.io.*;
import java.util.regex.*;
public class demo2{
public static void main(String[] args) throws IOException
{
String g="14";
char ch2=g.charAt(0);
char ch1=g.charAt(1);
System.out.println(ch2);
System.out.println(ch1);
File file1 = new File("prob.txt");
//StringBuffer contents = new StringBuffer();
BufferedReader reader = null;
String text=null;
try
{
reader = new BufferedReader(new FileReader(file1));
while ((text = reader.readLine()) != null) {
String []splits1 = text.split(" \\s+." );
for(int j=0; j< splits1.length ;j++){
if(splits1[j].length() > 0 )
{
//In this line I want to put the value which user select from a jsp page....for ex may user select
// 1 or 2 0r 3(it is working for number having more than on digit but not fore the digit having only one digit for ex.1,2,3...9
if(splits1[j].charAt(0) ==ch2 && splits1[j].charAt(1) == ch1)
{
System.out.println(splits1[j]);
int index = splits1[j].indexOf('(');
int index1 = splits1[j].indexOf(')');
int index2=index1+1;
String t = splits1[j].substring(index, index2);
System.out.println(t);
int index3 = splits1[j].indexOf('[');
int index4 = splits1[j].indexOf(']');
int index5=index4+1;
String t1 = splits1[j].substring(index3, index5);
System.out.println(t1);
}
}
}
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
}
see da line given :
if(splits1[j].charAt(0) ==ch2 && splits1[j].charAt(1) == ch1)
{
..its wrkin if digit contain two number ..but not for digit having one number for ex.1,2...9 ...Thanx all..Last edited by ras_pari; 10-08-2009 at 07:30 AM.
- 10-16-2009, 04:56 PM #2
Don't try to compare individual characters of the string of the number, just compare the string?
like:
Java Code:String g="14"; ... if(splits1[j].length() > 0 ) { // and here, compare the entire string if(splits1[j]..equals(g)) {
- 10-21-2009, 05:25 AM #3
Member
- Join Date
- Oct 2009
- Posts
- 40
- Rep Power
- 0
Similar Threads
-
Go back to previous page using session in JSP page
By gopikarikati009 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-23-2011, 10:30 AM -
setting the view to a jsp page from a self refeshing page
By deepal_205 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-15-2008, 04:41 PM -
i click on it,then first time error page comes,second time click then product page co
By 82rathi.angara in forum New To JavaReplies: 21Last Post: 08-01-2008, 11:13 AM -
warning that page has expired and i need to refresh the page again
By 82rathi.angara in forum JavaServer Pages (JSP) and JSTLReplies: 5Last Post: 07-15-2008, 01:48 PM -
help with jsp page
By praveena in forum New To JavaReplies: 3Last Post: 02-05-2008, 11:08 AM


LinkBack URL
About LinkBacks

Bookmarks