Home Answers Viewqa Java-Beginners To find palindrome no in a file

 
 


prashant
To find palindrome no in a file
1 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners

View Answers

April 14, 2009 at 10:10 AM


Hi Prashant,

Use the following code:

import java.util.Scanner;
import java.io.File;

public class palindromeExample {
static int counter;
public static boolean isPalindrome (String s) {
int low, high;
low = 0;
high = s.length()-1;
while (low<high) {
if (s.charAt(low) != s.charAt(high)) {
return false;
}
low++;
high--;
}
counter++;
return true;
}
public static void main(String args[]) throws Exception {
File infile = new File("C://Hello.txt";);
Scanner input = new Scanner( infile );
while (input.hasNext()) {
String word = input.nextLine();

if (isPalindrome(word)) {
System.out.printf("Found a palindrome: %s\n", word);
}
}
System.out.println("Number of Palindromes in the file: "+counter);
input.close();
}
}
Thanks









Related Pages:
To find palindrome no in a file - Java Beginners
To find palindrome no in a file  hi all i am having a problem...I wanted to write one java program where i have to count the no of palindrome in a file. I tried it with my own but not able to get result.pls help me out  
palindrome
palindrome  program to find the given string is palindrome...]; } if(st.equalsIgnoreCase(reversedSt)){ System.out.println("String is palindrome"); } else{ System.out.println("String is not palindrome
PALINDROME
PALINDROME  how to find palindrome of a number WITHOUT using a string... == reversedNumber){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e){ System.out.println(e
Palindrome
Palindrome  program to verify palindrome
complete the code (palindrome) - Java Beginners
complete the code (palindrome)  Write a program that checks if a word is palindrome. A word is said to be palindrome if it reads the same forward...: noon noon is a palindrome. Enter a word: moon moon is not a palindrome
palindrome
palindrome  write a program to print palindrome numbers between 500 to 700
palindrome - Java Beginners
palindrome  Write a program to find whether a given string is a palindrome or not  Hi Friend, Try the following code: import java.util.*; public class CheckPalindrome{ public static void main(String[] args
Find Numbers which are palindrome and prime
Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute...() of boolean type. Now the list contains all the numbers which are palindrome
palindrome
palindrome  how to write in string of palindrome?   import... is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  how to write in string of palindrome   import... is palindrome"); } else{ System.out.println("String is not palindrome
Finding all palindrome prime numbers - Java Beginners
Finding all palindrome prime numbers  How do i write a program to Find all palindrome prime numbers between two integers supplied as input (start and end points are excluded
Check whether the sum of alternate digit of a number is palindrome or not.
by the user is palindrome or not. So, firstly we have to find the sum...Check whether the sum of alternate digit of a number is palindrome... of this number be 2+4+6 i.e 12) and then check whether this sum is palindrome
java palindrome
java palindrome  sir i need java program to print 1)integer palindrome 2)string palindrome
prime palindrome
prime palindrome  Hi I want to write a program in pascal that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. thks
prime palindrome
prime palindrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime numbers that are palindrome below the number entered. In pascal language Thanks
How to find a config file in spring project
How to find a config file in spring project  how to find configuration file in the spring project
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
Find the percentage of words which starts with a vowel in a file
Find the percentage of words which starts with a vowel in a file   Question: Find the percentage of words which starts with a vowel in a file. Ex: Input: Contents of File1- There is an endless loop in the program. Output: Vowel
Program to find no of metrics in a file ----- Java code
Program to find no of metrics in a file ----- Java code  Hi Friends, I got a task to calculate the metrics of a program, like to find... the no of SELECT and INSERT statements but unable to find tablewise. E.G Table
find zip file length lessthen 5MB
find zip file length lessthen 5MB  import java.io.BufferedReader... File folder = new File(source); if(folder.exists... :"); detination=readkeyboard.readLine(); File[] files
Find the date of the file before the file has been modified
Find the date of the file before the file has been modified  Hi, may i know is it possible to find the date of the file before the file has been modified?   hi friend, you can get the date of last modified file using
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP  import java.util.*; import java.io.*; public class countunique { private String[] splitter...())); } System.out.println("Number of unique words in file "+cc
File
File   How to find all files in our local computer using java
palindrome - Java Beginners
palindrome  example of java program if it is a palindrome or not palindrome   Hi friend, Example to check the number is a palindrome...){ System.out.print("Number is palindrome!"); } else
Error 500-Server are not find the jar file in the program of upload the file - JSP-Servlet
Error 500-Server are not find the jar file in the program of upload... a program to upload a file.I include the commons-fileupload-1.2.1.jar file in lib...); // Create a new file upload handler System.out.println(isMultipart); DiskFileUpload
Need to find the position of delimiter in a file using java - Java Beginners
Need to find the position of delimiter in a file using java  Hi , will any one give me a solution to find the Need to find the position of delimiters in a file using java.Please do reply
palindrome - Java Beginners
is palindrome. A word is said to be palindrome if it reads the same forward... noon is a palindrome. Enter a word: moon moon is not a palindrome.  Hi...)) { System.out.println(str + " is a palindrome"); } else { System.out.println(str
palindrome - Java Beginners
palindrome  determines whether or not it is a palindrome. if the number is not five... == digit4)){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e  
palindrome - Java Beginners
palindrome in java code  I need an example of palindrome in Java ...;& (digit2 == digit4)){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"
find jar file name from multiple set of jar files
find jar file name from multiple set of jar files   I would like to find jar file name from multiple set of jar files where the given class nameââ?¬Â?com.rational.ft.util.debugââ?¬Â
Java: Example - Palindrome test
Java: Example - Palindrome test //========================================================= isPalindrome // This method returns 'true' if the parameter // is a palindrome, a word that is spelled the // same both
palindrome array problem
palindrome array problem  I'm having trouble figuring this assignment out. Can someone please help me? Generate (write the code) and save in an array Palidrome[250][5] all the 5 letter words using {a, b, c} Write the code
Exercise - Palindrome
Java: Exercise - Palindrome Problem Write a method which returns true if the string parameter is a palindrome. A palindrome is any "word" which... return false if the argument is not a palindrome. Signature
palindrome - Java Beginners
palindrome  import java.io.*; class Palindrome { System.out.println("Enter a word:"); BufferedReader br=new BufferedReader(new InputReaderStream(System.in)); String word; word=br.readLine(); public static void main
Java - search/find a word in a text file - Java Beginners
Java - search/find a word in a text file  Hello, I would like to know how to find from a list of lets say 10 but could be more, .txt files, how... want to do nothing, if FAIL, I want to record in 1 master output file, the name
Can find a solution or code for this - XML
Can find a solution or code for this   Develop a java based tool... the configuration file,mentioning the folders/files to be used.The tool then should read each of the file and build the GUI component.The components should
Palindrome Number Example in Java
Palindrome Number Example in Java    ... the palindrome number and how to determine any number is palindrome or not. First of all we are going to read about the palindrome number.  This is the number
Can not find "org.apache.poi " - JSP-Servlet
Can not find "org.apache.poi "  Hi friend, Thanks for giving me a solution.Thanks a lot.I have executed the program but it is showing... net but i m unable to download the jar file. So can u help me to do
Check whether the number is palindrome or not
Check whether the number is palindrome or not A palindrome is a word, phrase... is palindrome or not. You can check it in various ways but the simplest method...; } if (n == reversedNumber) { System.out.print("Number is palindrome
The Array Palindrome Number in Java
The Array Palindrome Number in Java       This is a Java simple palindrome number program. In this section you will read how to uses palindrome one dimensional array
Palindrome program in Java
Palindrome program in Java helps programmers to determine if a number or string is palindrome or not. palindrome number or string remains unchanged when.... The logic used in Java program behind finding a number or sting is palindrome
Find Type of Work Book
Find Type of Work Book       In this program we are going to find type... to find type of object that is marked. This method returns short type of object
find SQL query created by Criteria - Hibernate
find SQL query created by Criteria  Hi there, I am new... lignesDel = criteria.list(); where would I find my SQL code which is generated? Will it be in some DAO file or it is generated on the fly ? Thanks, Sandeep
Doclets Find Bad Code - Java Tutorials & Doclets Tutorial
Doclets Find Bad Code 2001-11-17 The Java Specialists' Newsletter [Issue 035] - Doclets Find Bad Code Author: Dr. Heinz M. Kabutz If you are reading... subscribed from 55 countries Doclets Find Bad Code What makes code bad
Find Name of Excel Sheet
is within the HSSF file.  getSheetname(): This method is used to find the name... Find Name of Excel Sheet       In this program we are going to find the name of an excel
Find Type of Excel Sheet
Find Type of Excel Sheet       In this program we are going to find type of an excel sheet... and workbooks getType(): This method is used to find type of object
Program to display palindrome numbers between some range
Program to display palindrome numbers between some range  Hi!I want a java program to display palindrome numbers between 100 to 1000.can you please explain me the logic with an example   import java.util.*; public
.jar file keeps giving me " could not find the main class". Program will exit.
.jar file keeps giving me " could not find the main class". Program will exit... even with a simple file that displays a jframe with a jlabel on it. My... clean and build it which produces a .jar file in my dist folder. When I double
Finding Last Modification Date of a file
This section contains the detail about how to get the last modification date of a file. This can be done by creating instance of the file using File Class... LastModificationDate { public static void main(String[] args) { File file = new
Java latest file
Java latest file In this section, you will learn how to find the file which is generated or modified at last. Description of code: To find the last modified file, we have used the Comparator interface that compare the files 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.