deepika deepi wrote:hi all,
i have an input like this in the text file
located 1
biosphere 2
reserve 3
in this i want to find if the text file has the word located. It should match the word and display the result as 1. How to do like that ? Help me...
deepika deepi wrote:hi all,
i have an input like this in the text file
located 1
biosphere 2
reserve 3
in this i want to find if the text file has the word located. It should match the word and display the result as 1. How to do like that ? Help me...
“If you’re good at something, never do it for free.” —The Joker
R. Jain wrote:
deepika deepi wrote:hi all,
i have an input like this in the text file
located 1
biosphere 2
reserve 3
in this i want to find if the text file has the word located. It should match the word and display the result as 1. How to do like that ? Help me...
And I thought you figured out how to do this??
And you don't need to create another topic for the same question.. You will get same answers..
deepika deepi wrote:
R. Jain wrote:
deepika deepi wrote:hi all,
i have an input like this in the text file
located 1
biosphere 2
reserve 3
in this i want to find if the text file has the word located. It should match the word and display the result as 1. How to do like that ? Help me...
And I thought you figured out how to do this??
And you don't need to create another topic for the same question.. You will get same answers..
ya... i was not actually double post yaar... the time i give on net the post , it was not posted. So i tried to post it in new one.. Sorry for that....
deepika deepi wrote:the input can also be
001 001001 located,reserve,biosphere,serve Rule1.2
and so on...
I can split using the delimiter. But the problem is i have many words with comma so i would like to know any other alternate solution existing for this problem ?
if i use for the words are initialised inside and cannot be used outside the for loop.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
What for loop? I don't see any.
However, if what I said above is correct, the solution is simple:
1. Split the line using TAB as a delimiter.
2. Split the 3rd element of the result of (1) using comma as a delimiter.
Winston
deepika deepi wrote:
Yor telling to use like this
String[] input = sentence.split("\t");
String integer = input[0];
String integer1 = input[1];
String keyword = input[2];
String rule = input[3];
String[] keywordsplit = keyword.split(",");
String integer = keywordsplit[0];
String integer1 =keywordsplit[1];
deepika deepi wrote:Yor telling to use like this
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Looks right to me, IF what I guessed about the format was correct.
Winston
Winston Gutkowski wrote:
deepika deepi wrote:Yor telling to use like this
Looks right to me, IF what I guessed about the format was correct.
Except for those last two lines. Why are you re-assigning integer and integer1 again?
keywordsplit[0] and keywordsplit[1] will be words, won't they?
Winston
deepika deepi wrote:ya they are keywordsplit[0] and keywordsplit[1] will be words
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
deepika deepi wrote:ya they are keywordsplit[0] and keywordsplit[1] will be words
Right, so don't put them in fields called 'integer...'. It's confusing.
Winston
R. Jain wrote:
deepika deepi wrote:
Yor telling to use like this
String[] input = sentence.split("\t");
String integer = input[0];
String integer1 = input[1];
String keyword = input[2];
String rule = input[3];
String[] keywordsplit = keyword.split(",");
String integer = keywordsplit[0];
String integer1 =keywordsplit[1];
Yes.. you did it right.. Check the duplicate names in variable declaration..
deepika deepi wrote:how to get the expected output from the actual output. Help me
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
deepika deepi wrote:code is:
i hope i am making it easier now. I have given all the datas. Help me.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
deepika deepi wrote:
code is:
deepika deepi wrote:the expected output is:
line output:located Rule1.0
line output:serve Rule1.0
the actual input is :
line output:located Rule1.0
line output:serve Rule1.1
Winston Gutkowski wrote:
deepika deepi wrote:code is:
No it isn't; because that code could not possibly produce the output you say it does.
i hope i am making it easier now. I have given all the datas. Help me.
As I said before, EaseUp. Simply repeating "Help me" isn't going to get the job done any quicker.
Read the HowToAskQuestionsOnJavaRanch page; and also this one and this one.
And when you've done that, come back and explain your problem, NOT your solution.
Winston
deepika deepi wrote:input file is:
001 001001 located,reserve Rule1.0
001 001001 reserve,biosphere Rule1.1
deepika deepi wrote:
deepika deepi wrote:
R. Jain wrote:
What will be size of array generated when you use the above split code??
deepika deepi wrote:size of the array is 15.
deepika deepi wrote:
keywordsplit[0] contain output: located serve chief
keywordsplit[1] contain output: reserve biosphere star
keywordsplit[2] contain output is not displayed
R. Jain wrote:
deepika deepi wrote:size of the array is 15.
In which case, you are not getting your code..
Try to print the array obtained as you split your keyword.. Also print its length..
deepika deepi wrote:
keywordsplit[0] contain output: located serve chief
keywordsplit[1] contain output: reserve biosphere star
keywordsplit[2] contain output is not displayed
No they don't.. Try printing array and see what you get..
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |