java word counting

java word counting

Hi I want a code in java that replaces a word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another word the run

View Answers

April 10, 2008 at 3:31 PM

Hi
Execute the program and check whether is this what you want...Please try to explain your question properly...


import java.util.Scanner;


public class ReplaceLetters
{
public static void main(String[] args)
{
Scanner input;

input = new java.util.Scanner(System.in);

String s,s1,s2;
String resultString;
int count = 0,len;


System.out.print( "Enter a string: " );
s = input.nextLine();
System.out.println("enter the letter to be replaced(which yiou want to change)");
s1=input.nextLine();
System.out.println("enter the letter to replace(your own)");
s2=input.nextLine();
resultString=s.replace(s1,s2);
System.out.println("------ new string -----"+resultString);
}
}
Thanks
pinky

April 10, 2008 at 6:07 PM

Pinky,

Thank you very much that was great
but this will change all the occurance even if its part of another word
the run of this program must be like this

> Enter text to be changed : fat
> Enter text to change it with : xxxxxx
> Enter the original text line :
the fat boy and his father

output:
the xxxxxx boy and his father

while your program will output the following for the same inputs

>the xxxxxx boy and his xxxxxxher

thank you if you can help

Hassan









Related Tutorials/Questions & Answers:
java word counting - Java Beginners
java word counting  Hi I want a code in java that replaces a word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another word the run
word and character counting - Java Beginners
word and character counting  here is the java code i made but i have to add something where it will read the inFile and display the number of words... = null; String word; int numLines = 0; int numWords = 0
Advertisements
letter counting for the smallest word
letter counting for the smallest word  How do I program my java... and it works EXCEPT that it counts all of the letters not just the smallest word...(); int count=ch.length; System.out.println("Count of smallest word
Counting specific word occurences in a file
Counting specific word occurences in a file  Hello I have a log file from the proxy which consists all the browsing history with date,time,url,ip address etc as fields.Now i need to take only main part of the url like the domain
Counting
Counting  Pl sir make a program which generate the following output on pop up menu. 1 12 123 1234 12345 123456 1234567 12345678 123456789   Java Print Pattern 1 12 123 1234 12345 123456 1234567 12345678 123456789
counting the positive,negative and zero nos. - Java Beginners
counting the positive,negative and zero nos.  Create a program that will input n number, and determine the number of positive, negative
counting identifiers,no.of inputs and outputs - Java Magazine
counting identifiers,no.of inputs and outputs  Hi, my name is jyothi.iam doing my miniproject the title is 'evaluation of complexity measure using... not getting....... plsssssss any one tell me it can be java for example #include
Counting the highest sequence of zeros and one's - Java Beginners
Counting the highest sequence of zeros and one's  Count the highest sequence value of '0's and '1's. for a given string with zeroes and ones. Input: You should ask user to enter any bit string with zeros and ones sequence
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Java Word Processor
Java Word Processor  Problem: Design and implement a class called... of words (a hyphenated word is one word), o number of sentences (ends...: ? You can break up a String into words or "tokens" by using java?s Scanner
Word replacment - Java Beginners
Word replacment  Java code for the Word Replacement.Thnaks in Advance!  Hipublic class WordReplaced{ public static void main(String[] args... information,http://www.roseindia.net/java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
word program - Java Beginners
word program  HELLO MAM AND SIR I ASK YOUR HELP HOPE YOU GONNA HELP ME THANK YOU!!Design a program to search a word for letters that the user... within the word a letter that the user entered,change the value of the array
Easy Counting Java Program...Please Help? - Java Beginners
Easy Counting Java Program...Please Help?  As I said, I am a beginner at Java. I came across this problem that Im sure uses java. Could you please tell me the code to do this and possibly explain? How many ways
java number to word - Java Beginners
java number to word  Can somebody please fix this to come out with the word, not the number 23? import java.util.Scanner; public class... { //----------------------------------------------------------------- // Pulls integers from a string to form a word
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
ModuleNotFoundError: No module named 'counting'
ModuleNotFoundError: No module named 'counting'  Hi, My Python... 'counting' How to remove the ModuleNotFoundError: No module named 'counting... to install padas library. You can install counting python with following
ModuleNotFoundError: No module named 'counting'
ModuleNotFoundError: No module named 'counting'  Hi, My Python... 'counting' How to remove the ModuleNotFoundError: No module named 'counting... to install padas library. You can install counting python with following
export to word document - Java Beginners
export to word document  hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in word document,automatically,plz provide program sir  Hi Friend, Try
create MS Word in Java - Java Beginners
which creates MS Word in Java...create MS Word in Java  Hi, Could any one please post the code which creates the word document having different paragraphs and two tables. i have
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Java word extraction program. - Java Beginners
Java word extraction program.  Need to code a public class named...- character word. The starting position should be based on the leftmost character... position and display the word on the console screen. Thanks
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Creating MS Word document in java - Struts
Creating MS Word document in java  I have one template in MS Word which has some content. Now i want to read this doc file and wants to add some... you plz tell me how to do in java
How to Open Text or Word File on JButton Click in Java - Java Beginners
How to Open Text or Word File on JButton Click in Java  How to Open Text or Word File on JButton Click in Java
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
Final Key Word in Java
.style1 { text-align: center; } Final key word in java In java final is a key word used in several different contexts. It is used before... is a final variable introduced in java 1.1, its declaration lacks
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
ModuleNotFoundError: No module named 'residue-counting'
ModuleNotFoundError: No module named 'residue-counting'  Hi, My... named 'residue-counting' How to remove the ModuleNotFoundError: No module named 'residue-counting' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'residue-counting'
ModuleNotFoundError: No module named 'residue-counting'  Hi, My... named 'residue-counting' How to remove the ModuleNotFoundError: No module named 'residue-counting' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cell_counting'
ModuleNotFoundError: No module named 'cell_counting'  Hi, My... 'cell_counting' How to remove the ModuleNotFoundError: No module named 'cell_counting' error? Thanks   Hi, In your python
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance

Ads