String.contains function not working


ElFenix
26/4/2016 6:52 am
HOME » Web Development

I have to check whether the words from File1 exist in File2 or not and then count. Data in both files is shown below.

The words in File1 are like shown below:

  1. 发表
  2. 发愁
  3. 发达
  4. 发抖
  5. 发挥

The data in File2 is like shown below:

  1. 这篇论文是什么时候发表的?
  2. 91 .数据 删掉 被马工程师 了
  3. 92 .驾驶 酒后 很大 危害
  4. 93 .客观地 要 他人 评价
  5. 94 .我不小心 水壶 打翻 了 把

The code I have written is as follows:

File file1 = new File("ChineseWord.txt");
        Scanner sc = new Scanner(new FileInputStream(file1));
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> newList = new
ArrayList<String>();

        while(sc.hasNext()){
                list.add(sc.next());
        }

        sc.close();

        File file2 = new File("RandomData.txt");

        Scanner newScanner = new Scanner(new FileInputStream(file2));

        int count = 0;

        for (int i = 0; i < list.size(); i++) {

            while(newScanner.hasNext()){

                String word = newScanner.nextLine();
                String toMatch = list.get(i);

                if(word.contains(toMatch)){
                    System.out.println("Success");
                    count++;
                }


            }

            String test = list.get(i);
            newList.add(test+"exists" + count+ "times");
            count =0;

        }

The question is that it returns 0 for all words whereas the very first word in File1 exists in the very first line of File2. If I manually do something like this

if(word.contains("发表")){
                        System.out.println("Success");
                        count++;
                    }

It prints successs otherwise it does not ? Why is this so?


Related to : String.contains function not working
String function not working
by James Dio in Web Development

Dear Sir,
I am trying to print the string with the following code,
but I am getting errors like
Undefined symbol 'string'
Undefined symbol 'str'.

#include<conio.h>#include<string.h>#include<iostream.h>void main(){string str = "M
String.contains function not working
26/4/2016 6:52 am by ElFenix in Web Development

I have to check whether the words from File1 exist in File2 or not and then count. Data in both files is shown below.

The words in File1 are like shown below:

  1. 发表
  2. 发愁
  3. 发达
  4. 发抖
  5. 发挥

The data in File2 is like sho


ChangePassword function/string not working
by rgmarcha in Web Development

Hey I been working on this script and im having one last problem, the chnge password function doesnt seem to be working. Everything else works perfectly.
PHP Code:
<?php
include_once("
Sending String to Function not working
by cthulhup in Web Development

I am trying to pass a string to this function:
Code:
void insert(ListNodePtr *sPtr, char *value);
I am gathering the string from scanf, printing it, and then passing it to the function l
String function not working while debugging.
by amiT jaiN in Web Development

Hi all,
I am facing some wierd problem in quick watch at a time of debugging
my application.
I have one variable of type string, say suppose i have code as below:
string FileName;
FileName = FileName.Substring(0,FileName.LastIndexOf("."));
At a time of debugg
String function in query not working
by Elieder in Web Development

I have an Access 97 database, which we use with a VB5 front end.
If I create a new query in the database, the string functions left, mid etc
do not work.
For example the query:
CalcField: Left([MyField],2) returns the correct number of records, but
CalcField contains only #E
String function in query not working :-
by Gábor in Web Development

I have an Access 97 database, which we use with a VB5 front end.
If I create a new query in the database, the string functions left, mid etc
do not work.
For example the query:
CalcField: Left([MyField],2) returns the correct number of records, but
CalcField contains only #E
Passing string to function not working!
by Dré in Web Development

So i need to make a program which reads in a string, then analyses the string and prints out how many of each letter are in the string (case is not important). It all works, except my string of 30 characters (defined in main, and debugger shows it has 30 spots in main), when passed into my function
parsename is not working when using string from function
6/1/2015 8:00 am by Matthew Steed in Web Development

Parsename is working when directly using string or returning static value from the function. But when I returning select value with dot from the function. its not working. I am not able to figure out the issue.

     CREATE TABLE [dbo].[TestTimeLine](
                [UserID] [int]
String.Format function not working
by Ali in Web Development

This seems like a really dumb problem, but I just haven't managed to get around it. Here is the code:


private string[] ConvertToCurrency(string[] costs)
{
int count = costs.Length;
for (int i = 0; i < count - 1; i++)
{
costs[i] = Stri


HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .