Shaik Jelani
Reading duplicate keys from .properties file
1 Answer(s)      6 years and 6 months ago
Posted in : Development process
Advertisement
View Answers

October 7, 2011 at 2:05 PM


Try this . It worked for me .

import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.FileInputStream;

import java.io.InputStreamReader;

public class Sample {

public static void main(String[] args) {

try {

        FileInputStream fstream = new FileInputStream("C:\\java\\prop\\message.properties");
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;
        String key[] = null;
        // Read File Line By Line
        while ((strLine = br.readLine()) != null) {
            if (strLine.contains("=")) {
                key = strLine.split("=");
                System.out.println(key[0]);


            } else {
                System.out.println(strLine);
            }
        }
        in.close();
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
    }









Related Tutorials/Questions & Answers:
Reading duplicate keys from .properties file - Development process
Reading duplicate keys from .properties file  Hi, I am reading a .properties file using a basic java program.Though the .properties file will not allow duplicate keys, but still I want to develope a program to identify
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
Advertisements
Detecting Duplicate Keys
Detecting Duplicate Keys  Detecting Duplicate Keys I have a program... constraint. If the user attempts to insert a duplicate name into the table, I want to display an error message by processing the error code from the database. How
Write Keys and Values to the Properties file in Java
Write Keys and Values to the Properties file in Java.... The program for writing keys and values to the properties file has been mentioned... to write or store the keys and values in properties file list. The OutputStream used
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading string from file timed
Reading string from file timed  So I want to make a file reader/ buffered reader that reads a new line of the textfile, lets say every 30 second. Like it reads the first line, waiting 30 seconds, read the next line and so one
Reading text from image file - Java Beginners
Reading text from image file  How Read text from image file
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
How to write .properties file from jsp
How to write .properties file from jsp  Hi i new to java i stuck here please help me... my problem is "I wrote a class to write the .properties file... to implement/write .properties file from jsp. Regards, Venkatesh Gurram
reading a csv file from a particular row
reading a csv file from a particular row  how to read a csv file from a particular row and storing data to sql server by using jsp servlet
Reading XML from a File
Reading XML from a File       This Example shows you how to Load Properties from the XML file via... File from where properties are to be loaded. DocumentBuilderFactory dbf
Loading properties from a XML file
Loading properties from a XML file       This Example shows you how to Load properties from a XML... parsers. Some of the methods used for loading properties from a XML file
need to update key , value pair in map from properties file
want the keys and values to be dynamically updated into map. that is i have .properties file where i will update the keys and values whenever needed. i want...need to update key , value pair in map from properties file  I have
initialise array by reading from file - Java Beginners
initialise array by reading from file  Hello, I wnat to know how i would initialise an array by reading a text file, which contains a simple pattern. for example the file may look as shown below, with the star character
Get All Keys and Values of the Properties files in Java
the features to collection of all keys and values of the properties file... is the video tutorial of: "How to get key and value from properties file in Java...Get All Keys and Values of the Properties files in Java
Write the Keys and Values of the Properties files in Java
will see in the properties file, your inserted keys and values had been inserted...): This method used to insert the keys and values in the properties file. This method... Write the Keys and Values of the Properties files in Java
Writing to and reading from a binary file in java.
Writing to and reading from a binary file in java.  I have written... the binary file from another program as follows: m_dis = new DataInputStream... work, but the records obtained after reading the binary file are much less than
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
reading data from excel file and plotting graph
reading data from excel file and plotting graph  I am doing a project using NetBeans in which i have to take input an excel file and then using... at the same time from one excel file using different columns..how can i do that? waiting
jar file not reading input from serial port
jar file not reading input from serial port  i used a coding for getting data from serial port. JOptionbox with "port not found" message is shown when i execute thru jar file. but when i execute thru netbeans, data is received
jar file not reading input from serial port
jar file not reading input from serial port  i used a coding for getting data from serial port. JOptionbox with "port not found" message is shown when i execute thru jar file. but when i execute thru netbeans, data is received
Properties file in Java
to read key and it's regarding values from the properties file.   ... Properties file in Java       Properties file in Java In this section, you will know
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... white spaces for removing all duplicate white spaces from the text file
PHP duplicate file - PHP
PHP duplicate file   i wanted to duplicate a PHP file resides in different directory on submission
Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java... to get all keys and values of the properties files in the Java. This section illustrates the way for getting all keys and corresponding values of the properties
Properties file in Java
. The properties file is a simple text file. Properties file contains keys and values for the specific key. Keys of properties file is always on left side and it's value... Properties file in Java      
Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute
Display non-duplicate words from file
Display non-duplicate words from file In this tutorial, you will learn how to read a text file and display non-duplicate words in ascending order. The given code reads the file and stored the file text into StringBuffer. The buffer
Java Read username, password and port from properties file
Java Read username, password and port from properties file In this section... the properties file and display the data from the database. Now to load the data from... to a stream or loaded from a stream using the properties file
reading multiple files from a directory and writing them into a single file
reading multiple files from a directory and writing them into a single file... file i get an empty text file can you guide me how to do this: /*this program reads multiple files * from a single directory. */ package elite.tech.com