Home Answers Viewqa Java-Beginners Character from text file

Have Programming Question? Ask it here!

mar
Character from text file
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners

October 21, 2009 at 4:41 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;

class CountCharactersFromFile {
public static void main(String[] args) throws Exception{
FileInputStream fstream = new FileInputStream("C:\\data.txt");
DataInputStream in = new DataInputStream(fstream);
String strLine="";
String str="";
while ((strLine = br.readLine()) != null) {

str+=strLine;
}
String st=str.replaceAll(" ", "");
char[]third =st.toCharArray();
System.out.println("Character Total");
for(int counter =0;counter<third.length;counter++){
char ch= third[counter];
int count=0;
for ( int i=0; i<third.length; i++){
if (ch==third[i])
count++;
}
boolean flag=false;
for(int j=counter-1;j>=0;j--){
if(ch==third[j])
flag=true;
}
if(!flag){
System.out.println(ch+" "+count);
}
}
}
}

Thanks

Character from text file - Java Beginners
Character from text file  Write a program that reads characters from a text file. Your program will count how many time each character appear in the text. Assume that the letters are case-sensitive. Example output
Count characters from text file in Java
Count characters from text file Using Java Here we are going to count the occurrence of each character from the text file. For this, we have used the BufferedReader  class to read the specified file. Then we have removed
read from the text file and displays the output as desired. Unable to read the rest...Read Lines from text file  Here's a brief desc of what my Java code does .. I'm using BufferedReader to read lines from a text files and split each
How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out?? ... to read each and every character from file and check for the required string
Count characters from text file in Java
is a java code that count the occurrence of each character from text file. import...Count characters from text file in Java  At the "Count chracters fro... the directory of the text file ("C:\text.txt"). I use Eclipse to run this code. I
Reading text from image file - Java Beginners
stop word removal from text file
stop word removal from text file  i need java source code for stop word removal from a text file
Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help
Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file
Importing data into sql plus from a text file...
Importing data into sql plus from a text file...  How to import a text file into oracle 10g enterprise edition directly to create tables and data
Importing data into sql plus from a text file...
Importing data into sql plus from a text file...  How to import a text file into oracle 10g enterprise edition directly to create tables and data
binary search tree from text file
binary search tree from text file  How so I go about constructing a binary search tree from a text file, which has letters and numbers, which must be sorted and printed in ascending order. E.g. Text file contents 3 apples pears
Program to read the text from a file and display it on a JFrame.
Program to read the text from a file and display it on a JFrame.  import javax.swing.*; import java.io.*; import java.lang.*; import java.awt.... with this is only the last character is been displayed on the tabbed frame(i.e
how to match the key word from a text file
how to match the key word from a text file  p>Hi all, I have the code to match the key word and from the text. I have input like this reader.txt... want to get the value from the called file and get the result. String regex1
Java search word from text file
Java search word from text file In this tutorial, you will learn how to search a word from text file and display data related to that word. Here, we have created a text file student.txt which consists of id, name and marks of few
convert data from pdf to text file - Java Beginners
convert data from pdf to text file   how to read the data from pdf file and put it into text file(.txt
Read specific column data from text file in java
Read specific column data from text file in java  My question is if my text file contain 15 columns and i want read specific column data from that text file then what code i should do
To dump 10lakh lines from a text file to a mysql table
To dump 10lakh lines from a text file to a mysql table  I need to dump a text file datas -100000 lines into a mysql table.i'm able to dump only 152000 lines only
Java Read Lines from Text File and Output in Reverse order to a Different Text File
Java Read Lines from Text File and Output in Reverse order to a Different Text File  I need to read a file that was selected by the user using... to another text file. When that is done the output values of that file need
Removing character from a string in sql.
Removing character from a string in sql.  How to remove or replace character from a string
Write records into text file from database
Write records into text file from database You have already learnt how to insert records from text file to database. But here we are going to retrieve records from database and store the data into the text file. For this purpose, we have
Search word from text file using Java
How to Search word from text file using Java In this section, we are going to search a word from the text file. For this, we have created a swing button... from the text file. Here is the code: import java.io.*; import
How to make a list from file text in J2ME - Java Beginners
How to make a list from file text in J2ME  I was trying to make a method that read file from text and make a list of it, I have tried ReadHelpText...) { } return null; } kamus.txt file contains: iconSebuah lambang kecil berupa gambar
Removing character from a string in sql.
Removing character from a string in sql.  Removing special characters from a string in sql
How to extract a specific line from a text file? - IoC
How to extract a specific line from a text file?  Hi all, i'm trying to write a code that return a specific line from a text file. so my first...° 100 to 120 for example. My Text file contain numbers and words. How i have
how to create text file from jsp and provide downlode option
how to create text file from jsp and provide downlode option  HI... file so that pepole can downlode that text file or may be some other file formate... of this page in text file and also downlode option of this text field thanks
create login page using data from text file
create login page using data from text file  I want to create login page using data store in textfile(data submit from regiter page to textfile) using jsp and servlet. Thanks
Removing duplicate white spaces from a text file
Removing duplicate white spaces from a text file  ... duplicate white spaces from a specific text file. In this section a program is given... spaces from the given text file. This program reads the file line-by-line for search
text file
at the start of the program from a seperate external text file.Thank you! mport...text file  Hi can you help me I have to modify the program below so that all the data held in it is stored in an external text file.So there should
Get Character from String
Get Character from String     ... of character and retrieve elements from that character array one by one... toCharArray() to convert string to character array. 3. Retrieve character from
text file
text file  Hello can I modify the program below so that all the numerical data is stored in an external text file,that is the data contained in the array list.Thank you! mport java.util.*; import java.text.*; import
Java Remove a character from string
Java Remove a character from string In this tutorial, you will learn how to remove a character from the string. There are several methods for examining... to remove a particular character from the string. In the given example, we have
Java Write To File From String
Java Write To File From String In this tutorial you will learn how to write to file from string. Write to file from string using java at first we will have... in which I have created a new text file using the File constructor
Writing to File in Java
Writing to File in Java Writing any character or text in Java file is possible... are used for writing Character files and Text Files respectively while another class...) This is the simplest example of the class used for writing character file. BufferedWriter
Reading a text file in java
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
Sorting text file
Sorting text file  Hello friends, i'm writing search page for my local website. i'm storing all file list in text file. And also adding a value... according to begin value. Text File having list like this: 5| 3| can anyone
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import...); System.out.println("Text is inserted into pdf file"); document.close... FileReader( Input File)); String inLine = null
inserting text into text file using java application
inserting text into text file using java application  Hi, I want to insert a text or string into a text file using java application
how to update the text file?
how to update the text file?  if my text file contains a string and integer in each line say,: aaa 200 bbb 500 ccc 400 i need a java code to update the integer value if my input String matches with the string in file. please
uploading a text file into a database  how to upload a text file... { static File file; public static void main(String[] args) throws Exception { JLabel label=new JLabel("Choose File
PHP get character from String
PHP Get Character From String To get sub string from a String we can use substr() method. Structure of this method is : string substr (string $var, int$initial [, int \$len]  ) In the above example we want to get a sub
how to update the text file?
how to update the text file?  my textfile with name list.txt: Rice... in my text file, if the item i entered matches with item in text file.how can i...]; for(int i=0;i File file ; FileReader fr=null ; FileWriter
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program