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 8782299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:04+00:00 2026-06-13T20:32:04+00:00

So my program compiles but when testing the early analysis I realized it does

  • 0

So my program compiles but when testing the early analysis I realized it does not print the file showing all the output. Can someone please show me why the file isn’t being printed at all? Here’s my code…

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

public class Analyzer     
{         

private static FileWriter stream;    
        private static BufferedWriter output;

    public static void start() throws IOException

{       
    int i = 0;
    int total = 0;
    int totalError = 0;
    final int SIZE = 40000;
    Response data[] = new Response[SIZE];

    stream = new FileWriter("apacheOut.txt");
    output = new BufferedWriter(stream);

    Scanner scan = new Scanner("access_log1.txt");
    scan.useDelimiter ("[-\t]+");
    while (scan.hasNextLine()) 
    {
        double address = scan.nextDouble();
        String date = scan.next();
        String request = scan.next();
        int status = scan.nextInt();
        int bytes = scan.nextInt();
        String refer = scan.next();
        String agent = scan.next();

        if (Integer.toString(status).substring(0, 1) == "4" || Integer.toString(status).substring(0, 1) == "5")
        {
            ErrorResponse er = new ErrorResponse (address, date, request, status, bytes, refer, agent);
            totalError++;
        }
        else
        {
            SuccessResponse sr = new SuccessResponse (address, date, request, status, bytes, refer, agent);
        }

        total++;
    }

    int numGet = 0;
    int numPost = 0;
    double numBytes = 0;
    for (i = 0; i <= SIZE; i++)
    {   
        double address = data[i].getAddress();
        String date = data[i].getDate();
        String request = data[i].getRequest();
        int status = data[i].getStatus();
        int bytes = data[i].getBytes();
        String refer = data[i].getRefer();
        String agent = data[i].getAgent();

        /** GET/POST count */
        if (request.substring(0,1) == "G")
        {   
            numGet++;
        }
        else if (request.substring(0,1) == "P")
        {
            numPost++;
        }

        /** Number of total bytes */
        numBytes = bytes++;
    }

    output.write("Warren Smith's Results");
    output.write("======================");
    output.write("The total number of requests in the file: " + total);
    output.write("The total number of GET requests: " + numGet);
    output.write("The total number of POST requests: " + numPost);
    output.write("The total number of bytes served: " + numBytes);
    output.write("The number & percentage of pages producing various status categorizations:" );
    output.write("    1xx Informational: ");
    output.write("    2xx Status: ");
    output.write("    3xx Redirection: ");
    output.write("    4xx Client Error: ");
    output.write("    5xx Server Error: ");
    output.write("The percentage and number of Windows-based clients: ");
    output.write("The percentage and number of bad requests: ");
    output.write("The percentage and number of clients that are Mozilla-based: ");
    output.write("The percentage and number of requests from the Googlebot: ");

    output.close();
}
}
  • 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-13T20:32:05+00:00Added an answer on June 13, 2026 at 8:32 pm

    Always use .equals() method to check if two strings are equals
    change this

        if (Integer.toString(status).substring(0, 1) == "4" || Integer.toString(status).substring(0, 1) == "5")
    

    to

    if (Integer.toString(status).substring(0, 1).equals("4") || Integer.toString(status).substring(0, 1).equals( "5"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program compiles fine, but crashes everytime throw (not inside of a try...catch block)
I'm writing a simple program for testing mouse. It compiles fine, but doesn't work.
My program compiles fine, but gets core dumped when an overloaded function is called.
If I'm not mistaken, NUnit is the de-facto standard for unit testing, but I've
I'd like to compile my program with the -Wall switch but the library I
The following C++ program compiles and runs as expected: #include <stdio.h> int main(int argc,
So the program compiles fine, and the executable is generated in $(SolutionDir)/Debug. When I
I am trying to compile the SFML 2.0 tutorial with Eclipse. The program compiles
I am trying to enable link time optimization in g++. My program compiles fine
This program in C runs and compiles well : #ifdef HAVE_CONFIG_H #include <config.h> #endif

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.