groupby functionality in java

groupby functionality in java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
class Groupby{
    BufferedReader readexistingfile = null;
    String oldfileline;
    BufferedWriter writenewline = null;
    BufferedReader readnewfile = null;
    ArrayList<String> stringList = new ArrayList<String>();
    public void duplicate(String filename) {
        try {
        readexistingfile = new BufferedReader(new FileReader(filename));
        while((oldfileline = readexistingfile.readLine()) != null){
            //System.out.println("?????????"+oldfileline);
            //ArrayList<Integer> arry[] = oldfileline.split(",");
            newfile(oldfileline);
        }
        }catch(FileNotFoundException fnot){}
        catch(IOException io){}
        finally{
            try {                
                if(readexistingfile != null)readexistingfile.close();               
            } catch (IOException ex) {
                ex.printStackTrace();
            }   
        }
    }
    public void newfile(String line) {
        //System.out.println("------"+line);
        try {
        // boolean flag = false;
        writenewline = new BufferedWriter(new FileWriter("d://groupfile.txt"));
        //readnewfile = new BufferedReader(new FileReader("d://groupfile.txt"));

        stringList.add(line);

         for(int i=0;i<stringList.size();i++) {
                    //System.out.println("loop"+stringList.size());
               if(!(stringList.get(i).equals(line))) {
                    System.out.println("equals"+line);
                     writenewline.write(line);
                     writenewline.newLine();
                     writenewline.flush();  
                    }
               else{
                   break;
               }
               }         
        } catch(IOException io){}
    }
    public static void main(String arg[]){
        Groupby group = new Groupby();
        group.duplicate("d://raju.txt");        
    }
}
View Answers

Ads









Related Tutorials/Questions & Answers:
groupby functionality in java
groupby functionality in java  import java.io.BufferedReader; import... java.util.ArrayList; class Groupby{ BufferedReader readexistingfile = null...){} } public static void main(String arg[]){ Groupby group = new Groupby
groupby implement in java
groupby implement in java  **import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays
Advertisements
groupby implement in java
groupby implement in java  **import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays
sms functionality
sms functionality  i want to implement sms functionality in web site for sending as well as receiving.i am using jsp and xamp as backend.please guide me
Undo/Redo functionality in UITexView
Undo/Redo functionality in UITexView  Hi all, I m facing a big problem from some days, actually i want to integrate the Undo/redo functionality in iphone app, where m using a textview. Please tell me the proper sample that where
search functionality with in application
search functionality with in application  I have created on web based web site in struts. i want to give user functionality for search any link with in my application. for that i have created one textbox and one submit
Disabling Login Functionality
this onclick functionality when the user is already in session. I am using onclick
Version of com.transficc>transficc-functionality dependency
List of Version of com.transficc>transficc-functionality dependency
search functionality using jsp from database
search functionality using jsp from database  search functionality using jsp from database
Maven Dependency transficc-functionality >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.transficc >> transficc-functionality version1.0.1 in your project
Maven Dependency transficc-functionality >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.transficc >> transficc-functionality version1.0.0 in your project
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
how to add pageup page down functionality in scrolpane
how to add pageup page down functionality in scrolpane  how to add pageup page down functionality in scrolpane. In my GUI untill i dont click on screen area , the page up & pagedown button not works . what should i do to make
How to add "View more results" kind of functionality in my PHP based website?
How to add "View more results" kind of functionality in my PHP based website?   Hi, I want to make a website which will recommend users books according to the genre selected by them. I am using PHP, JavaScript and mySQL
Hibernate Criteria GroupBy Example
Hibernate Criteria GroupBy Example In this Example, We will discuss about hibernate criteria query, The class org.hibernate.criterion.Projections ... roseindia.util.HibernateUtil; public class Criteria_GroupBy_Example { public static
Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relat
Match the name with a description of purpose or functionality... or functionality, for each of the following deployment descriptor elements... Java identifier and MUST be UNIQUE within the ejb-jar file
Java API
Java API what is Java API? API stands for Application Programming Interface, an API can define how a programmer can access a functionality within a library of code. Java Application Programming Interface is a library of classes
Java Glossary Term - J
Java Glossary Term - J       Java DB Java DB is an open source Apache Derby database supported by Sun. Java DB is completely written in the Java programming language having
Java example program to get the environment variable
Java example program to get the environment variable       java get environment variable The getenv() method of the java.lang.System provide us the functionality to get
What are Chained Exceptions?
What are Chained Exceptions in Java?   ... causes an another exception, that is termed as Chained Exception. Java provides new functionality for chaining exceptions. Exception chaining (also
Example of Variable Support Tags of JSTL Core Tag Library
Example of Variable Support Tags of JSTL Core Tag Library       JSTL( Java Sever pages Standard Tag Library) provide simple tags of core functionality that are used in many web
Log4J Tutorials: Using Log4J in Easy Steps
Log4J Tutorials: Using Log4J in Easy Steps Log4j is a logging library for Java... Software Foundation. Log4j is one of best Java logging frameworks used by the developers for inserting logging functionality in the projects and add log
Java package
Java package       Introduction to Java Package Package is a mechanism for organizing a group... into  different directories according to their functionality, usability
Multicast Server in Java
Multicast Server in Java       This section introduces how to receive and send the IP packet by the multicast server and provides the functionality
JAVA
JAVA   I M building a media player using jframes using libraries of jmf and done with all things but left with some problems.. 1) not able show the timing of song.. 2) not able to volume functionality
Event on Slide bar In Java
Event on Slide bar In Java       Introduction In this section, you will learn about the event... solution for the appropriate functionality by providing a program. Program Description
June 2008 Issue of Java Jazz up magazine
June 2008 Issue of Java Jazz up magazine     ... popular. Web Services allows you to expose the functionality of your... Source web services tool in java The intention
Tomahawk Tags
Tomahawk Tags         Tomahawk tags are collection of standard components with extended functionality and many more extra set of components with rich set of functionality
Tomahawk Tags
with extended functionality and supports all the existing JSF components with additional sets of functionality. Some tomahawk tags are described in the subsequent sections
JSF Tags - Tomahawk Tags
with extended functionality and many more extra set of components with rich set of functionality. If you are going to create a web application in JSF then Tomahawk
Calendar Example
Calendar Example       In this section, we are discussing the entire functionality... is the output: C:\Examples>java CalendarExample

Ads