Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in this coding i tries to read the lines specific with and write on another notepad.this coding works well for english characters.but for tamil if i tries to count it count as:

(e.g)தமிழ்

it counts as 5..(i.e)"த", "ம", "ி", "ழ" and "்".
but i want to count it as 3(i.e)"த", "மி" and "ழ்"

What I have tried:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class ii {

public static void main(String[] args) {
    FileReader fr = null;
    BufferedReader br =null;
    FileWriter fw=null;
    BufferedWriter bw=null;

    String [] stringArray;
    int counLine = 0;
    int arrayLength ;
 String s="";
   String stringLine="";
 
   try{
        fr = new FileReader("F:\\New folder (2)\\N.txt");
        fw=new FileWriter("F:\\New folder (2)\\o.txt");
        br = new BufferedReader(fr);
        bw=new BufferedWriter(fw);
      while((s = br.readLine()) != null){
            stringLine = stringLine + s;
            stringLine = stringLine + " ";
            counLine ++;  
        }
        stringArray = stringLine.split(" ");
        arrayLength = stringArray.length;
    for (int i = 0; i < arrayLength; i++) {
            int c = 1 ;
            for (int j = i+1; j < arrayLength; j++) {
                if(stringArray[i].equalsIgnoreCase(stringArray[j])){
                   c++;
                   for (int j2 = j; j2 < arrayLength; j2++) 
                      {
                       }}
             int k;
              for(k=2;k==stringArray[i].length();i++)
              {
              bw.write(stringArray[i]);
               bw.newLine();
              
              }}} fr.close();
        br.close();
        bw.flush();
            bw.close();
    }catch (Exception e) {
        e.printStackTrace();
    }}}
Posted
Updated 15-Sep-16 5:26am
v2

1 solution

Quote:
(e.g)தமிழ்

it counts as 5..(i.e)"த", "ம", "ி", "ழ" and "்".
but i want to count it as 3(i.e)"த", "மி" and "ழ்"

Your problem comes from the fact that some chars are compound of more than 1 char.
Some chars have sufix
aka "மி" is compound of a leading char "ம" and a suffix char "ி".

I don't know your alphabet, but rather than reading chars 1 by 1 like with Latin alphabet, you have to detect if a char have a suffix or not.
Either you need a list of all combination of char+suffix, either you have to check if actual char is followed by a suffix char.

In any case you need to change your code to handle the situation.

[Update]
Quote:
yes i have possible letters in a string

String s = "ஃஅஆஇஈஉஊஎஏஐஒஓஔக்ககாகிகீகுகூகெகேகைகொகோகௌங்ஙஙாஙிஙீஙுஙூஙெஙேஙைஙொஙோஙௌச்சசாசிசீசுசூசெசேசைசொசோசௌஞ்ஞஞாஞிஞீஞுஞூஞெஞேஞைஞொஞோஞௌட்டடாடிடீடுடூடெடே";

Then you have to check if actual char and next one are in the string.
 
Share this answer
 
v2
Comments
Member 12200805 15-Sep-16 11:58am    
yes i have possible letters in a string

String s = "ஃஅஆஇஈஉஊஎஏஐஒஓஔக்ககாகிகீகுகூகெகேகைகொகோகௌங்ஙஙாஙிஙீஙுஙூஙெஙேஙைஙொஙோஙௌச்சசாசிசீசுசூசெசேசைசொசோசௌஞ்ஞஞாஞிஞீஞுஞூஞெஞேஞைஞொஞோஞௌட்டடாடிடீடுடூடெடே";
Member 12200805 15-Sep-16 12:15pm    
ho to use this String s in coding
Patrice T 15-Sep-16 12:24pm    
Look a Java documentation.
There is a string function that say if a little string is inside a big one.
with VB the name is INSTR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900