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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:14:01+00:00 2026-06-11T09:14:01+00:00

I work at a printing company that has many programs in COBOL and I

  • 0

I work at a printing company that has many programs in COBOL and I have been tasked to
convert the COBOL programs into JAVA programs. I’ve run into a snag in the one conversion. I need to take a file that each line is a record and on each line the data is blocked.

Example of a line is

60000003448595072410013 FFFFFFFFFFV 80     0001438001000014530020120808060134

I need to sort data by a 5 digit number at the 19-23 characters and then by the very first character on a line.

BufferedReader input;
BufferedWriter output;

String[] sort, sorted, style, accountNumber, customerNumber;
String holder;

int lineCount;

int lineCounter() {

    int result = 0;
    boolean eof = false;

    try {
        FileReader inputFile = new FileReader("C:\\Users\\cbook\\Desktop\\Chemical\\"
             + "LB26529.fil");
        input = new BufferedReader(inputFile);

        while (!eof) {

            holder = input.readLine();
            if (holder == null) {
                eof = true;
            } else {
                result++;
            }
        }

    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }

    return result;
}

chemSort(){
    lineCount = this.lineCounter();
    sort = new String[lineCount];
    sorted = new String[lineCount];
    style = new String[lineCount];
    accountNumber = new String[lineCount];
    customerNumber = new String[lineCount];

    try {
        FileReader inputFile = new FileReader("C:\\Users\\cbook\\Desktop\\Chemical\\"
             + "LB26529.fil");
        input = new BufferedReader(inputFile);

        for (int i = 0; i < (lineCount + 1); i++) {
            holder = input.readLine();
            if (holder != null) {
            sort[i] = holder;
            style[i] = sort[i].substring(0, 1);
            customerNumber[i] = sort[i].substring(252, 257);
            }
        }
        } catch (IOException e) {
            System.out.println("Error - " + e.toString());
    }
}

This what I have so far and I’m not really sure where to go from here or even if this is the correct way
to go about sorting the file. After the file is sorted it will be stored into another file and processed
again with another program for it to be ready for printing.

  • 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-11T09:14:01+00:00Added an answer on June 11, 2026 at 9:14 am
    List<String> linesAsList = new ArrayList<String>();
    String line=null;
    while(null!=(line=reader.readLine())) linesAsList.add(line);
    
    Collections.sort(linesAsList, new Comparator<String>() {
      public int compare(String o1,String o2){
        return (o1.substring(18,23)+o1.substring(0,1)).compareTo(o2.substring(18,23)+o2.substring(0,1));
      }});
    
    for (String line:linesAsList) System.out.println(line); // or whatever output stream you want
    

    This phone’s autocorrect is messing up my answer

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

Sidebar

Related Questions

I have a printing solution for ExtJS objects that seems to work great for
Im building a small webshop and have run into a problem. The company which
I work with unordered_set . Here it's written that it has a reserve function
It's a pretty classic problem. The company I work for has numerous business reports
First some background: The company I work for have decided to create an iPhone
I'm printing some labels on a Zebra TLP-2844 printer, and have been doing it
We have a process at our company that processes TIFF images. I have a
The company that I work for is redeveloping an in-house product for external use.
One of the projects I work on has some pre-existing reports that are printed
We (the company I work for) need to run the find2perl script on over

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.