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

  • Home
  • SEARCH
  • 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 6020007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:30:17+00:00 2026-05-23T03:30:17+00:00

I have a file that looks like this (but is much bigger): >some text

  • 0

I have a file that looks like this (but is much bigger):

>some text
ABC
DEF
GHI
>some more text
JKL
MNO
PQR

I have been playing around with it in Java for some time and have been able to build arrays with the lines, etc. The lines with ‘>’ are usually one line but sometimes could be 2, 3 or more lines. The lines that don’t begin with ‘>’ are the same length in characters but there may be 10, 20 or 30 or more of these lines. I am at the point now where I want to create an string array, where each string in the array contains a string of the lines that don’t begin with ‘>’ like so:

array element 1 = ABCDEFGHI
array element 2 = JKLMONPQR

I feel like I am close but need a small kick in the butt to get me going. I’m sure this is easy for a pro, but I am still new to Java.

Specific problem is related to other posts I made on this board. It’s a FASTA file:

>3BHS_BOVIN (P14893) 3 beta-hydroxysteroid
AGWSCLVTGGGGFLGQRIICLLVEEKDLQEIRVLDKVFRPEVREEFSKLQSKIKLTLLEG
DILDEQCLKGACQGTSVVIHTASVIDVRNAVPRETIMNVNVKGTQLLLEACVQASVPVFI
>41_BOVIN (Q9N179) Protein 4.1 
MHCKVSLLDDTVYECVVEKHAKGQDLLKRVCEHLNLLEEDYFGLAIWDNATSKTWLDSAK
EIKKQVRGVPWNFTFNVKFYPPDPAQLTEDITRYYLCLQLRQDIVSGRLPCSFATLALLG
SYTIQSELGDYDPELHGADYVSDFKLAPNQTKELEEKVMELHKSYRSMTPAQADLEFLEN
>5NTD_BOVIN (Q05927) 5'-nucleotidase 
MNPGAARTPALRILPLGALLWPAARPWELTILHTNDVHSRLEQTSEDSSKCVNASRCVGG
VARLATKVHQIRRAEPHVLLLDAGDQYQGTIWFTVYKGTEVAHFMNALGYESMALGNHEF
DNGVEGLIDPLLKEVNFPILSANIKAKGPLASKISGLYSPYKILTVGDEVVGIVGYTSKE
TPFLSNPGTNLVFEDEITALQPEVDKLKTLNVNKIIALGHSGFEVDKLIAQKVKGVDVVV

I ultimately need the sequences in their own array element so that I can manipulate them later.

  • 1 1 Answer
  • 1 View
  • 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-05-23T03:30:18+00:00Added an answer on May 23, 2026 at 3:30 am

    Assuming you can iterate over the lines:

    List<String> array = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    for (String line : lines) {
      if (line.startsWith(">")) {
        if (buf.length() > 0) {
          array.add(buf.toString());
          buf.setLength(0);
        }
      } else {
        buf.append(line);
      }
    }
    if (buf.length() > 0) { // Add the final text element(s).
      array.add(buf.toString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that looks something like this: ABC DEF GHI I have
I have some data in a text file that looks like this: 1895723957 8599325893
I have a text file that looks like this. A 102 B 456 C
I have a text file that looks like this: value1 value2 value3 There are
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return
I have a text file that looks like this: 1,Smith, 249.24, 6/10/2010 2,Johnson, 1332.23,
Ok, so I have an XML file that pretty much looks like this: <Templates>
I have a file that contain lines that looks like this: >AF001546_1 [88 -
I have a file that contain list of numbers that looks like this: 10^-92
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123

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.