Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7733357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:58:02+00:00 2026-06-01T06:58:02+00:00

I need a program that reads from multiple files and displays a report based

  • 0

I need a program that reads from multiple files and displays a report based on the date range entered by the user.Data in the files looks like:

[C445] ComputerName:FRONTOFFICE UserID:YB Yenae Ball Station 7A  LanId: | (11/23 17:01:55) | Client is disconnected from agent.
[C445] ComputerName:FRONTOFFICE UserID:YB Yenae Ball Station 7C  LanId: | (11/23 17:02:00) | Client is connected to agent.
[C7AE] ComputerName:KCUTSHALL-PC UserID:GO kcutshall Station 9901  LanId: | (11/23 13:33:06 - 11/23 13:33:41)|Client is disconnected from agent.

I need output like:

Computer Name   No.of disconnects
A                   4
B                   2
C                   1

i.e No. of disconnects for a particular computer name in descending order corresponding to the entered date range.
I tried doing it but I’m not able to get a consolidated count for the computers and also m unable to do the sorting.The output I got is:

Computer Name No. of disconnects

A               1
A               1
A               2
B               1
B               2
C               1
C               1

Please help me on this. Here is the code I wrote

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.Scanner;
import java.util.*;
import java.text.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;


public class ReadZip{
    public static void main(String args[]) throws ParseException {
        try {
            Scanner input1=new Scanner(System.in);

            Scanner input2=new Scanner(System.in);
            System.out.println("Enter start date");
            String userDate1=input1.nextLine();
            System.out.println("Enter end date");
            String userDate2=input2.nextLine();
            DateFormat df = new SimpleDateFormat ("MM/dd");
            Date d1=df.parse(userDate1);
            Date d2=df.parse(userDate2);

            ZipFile zf=new ZipFile("C:\\Users\\Engineeir\\Desktop\\QoS_logs.zip");
            Enumeration entries=zf.entries();

            BufferedReader input=new BufferedReader(new InputStreamReader(
            System.in));
            while (entries.hasMoreElements()) {
                ZipEntry ze=(ZipEntry) entries.nextElement();

                BufferedReader br=new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
                String line; String name;String compnames;int lines=0;
                while ((line=br.readLine())!=null) {

                    String[] st=line.split("\\|",-1);

                    if(st.length>1){
                        String dates=st[1];
                        String[] parts=dates.split("-");
                        SimpleDateFormat f=new SimpleDateFormat("(MM/dd");
                        String[] ob=parts[0].split(" ");
                        String finaldate=ob[1];

                        Date d3=f.parse(finaldate);

                        if(d3.after(d1) && d3.before(d2)){
                            compnames=getName(st);
                            if(line.contains("Client is disconnected from agent")==true)
                            {
                                //compnames=getName(st);
                                lines++;
                            }
                        System.out.println(compnames+"\t"+lines);}
                        else{break;}
                        //System.out.println(compnames+"\t"+lines);

                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getName(String[] st)
    {
        String[] name=st[0].split("\\:",-1);
        String[] comp=name[1].split("\\ ",-1);

        return(comp[0]);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:58:04+00:00Added an answer on June 1, 2026 at 6:58 am

    Instead of printing as you go, try accumulating the data in a map (key: computer name, value: number of disconnects). Then sort on the map keys and print the final totals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that reads arbitrary data from a file system and outputs
I'm trying to write a java program that reads data from an image and
I have a section of code that I need to remove from multiple files
I need to write a program that reads in either from ifstream or cin,
I'm writing a program that reads from a list of files. The each file
I need to write a simple program that records all the input from parallel
So for Homework I have to create this program that reads from a text
I've got a Java software that reads settings from properties files and database, reads
I have a program that reads in serial information from a device and that
I have a PHP program that reads from the database and generated formatted sheets.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.