Results 1 to 2 of 2
- 10-24-2011, 02:32 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 6
- Rep Power
- 0
Values of elements using regular expression
Hello. Please help! do not get.
File in.properties (pairs key=value) contains some sequence of lines.
Let the element with key indexi has the value j (i=1..n, j=1..m – natural numbers without leading zeros). It determines the index of an element with name valueij (j = indexi) you should work with.
1) Print the sum of values of elements, having the key valueij (see examples below).
2) Print the number of index elements with “errors” (i, j – unnatural numbers; no correct value-element for sum).
The example of the file in.properties:
index1 = 3
value11=qw
value12=4
value13 = 5.1
value14=2.7
index2=15
value21=
value22=
value23=
value24=k
value25=5
index3=1
value31= 3.14
value32=fgh
value33=5
index4=0
value41=
value42=e1
value43=2
value44=3
index5=b
value51=d
value52=e
Output:
sum = 8.24
error-lines = 3
I read from a file as follows:
How now?Java Code:ResourceBundle rb = ResourceBundle.getBundle("in"); Enumeration<String> keys = rb.getKeys(); String key; while(keys.hasMoreElements()) { key = keys.nextElement(); ... }
I cant do the third day. Please, help!
P.S. Sorry for my english
- 10-24-2011, 03:31 PM #2
Member
- Join Date
- Sep 2011
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Regular Expression Help
By niketanand in forum Advanced JavaReplies: 1Last Post: 06-24-2011, 04:56 PM -
regular expression
By ehsansad in forum New To JavaReplies: 8Last Post: 03-18-2011, 02:23 PM -
regular expression
By prof.deedee in forum JDBCReplies: 3Last Post: 02-19-2010, 11:15 AM -
regular expression
By QkrspCmptPop in forum Advanced JavaReplies: 8Last Post: 01-20-2010, 03:55 AM -
regular expression
By ras_pari in forum Advanced JavaReplies: 27Last Post: 10-07-2009, 12:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks