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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:31+00:00 2026-05-23T15:51:31+00:00

I have a mobile app that I’ve written for iPhone (Objective-C) that allows users

  • 0

I have a mobile app that I’ve written for iPhone (Objective-C) that allows users to import data using a specific format. I have the same app written for Android in Java and I’ve had users start asking for the ability to import. The format of the data is a portable standard that folks who write apps like this have to be able to import and export.

While I did write what I’m about to ask in Objective-C, I have a feel that I could have made my life quite a bit easier by doing it a different way. So, I’d like to ask how you’d parse the following TLV in Java. I don’t need code, just the gist.

Here’s the TLV format:

<Type:Length>Value<Type:Length>Value<Type:Length>Value<end>

Each record starts with < and ends with <end>. \n within records is acceptable and zero length values are okay.

Here’s an example input describing four different cars, note the multi-line record and the zero length value.

<make:4>ford<model:7>contour<color:3>red<end>
<make:5>mazda<model:3>mpv<color:5>black<end>
<make:3>bmw
<model:3>335
<color:6>yellow
<end>
<make:7>unknown<model:0><color:4>grey<end>

Once the data is parsed, I’ll be inserting it into an SQLite DB so ultimately looping the data by each record will result in a bunch of strings that I can use as part of the INSERT statement.

Thanks for any ideas you can provide!

Nick

  • 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-05-23T15:51:32+00:00Added an answer on May 23, 2026 at 3:51 pm

    Very strange format. Is there a published specification?

    You can try doing the string tokenization route. You could leverage the built-in Java regex to help with the matching, or even just use basic String class methods (split and trim being your friend). Basically just do:

    String[] lines = input.split("<end>");
    for(String line : lines)
    {
        line = line.trim();
        String[] sublines = line.split("<");
        for(String subline : sublines)
        {
            subline = subline.trim();
            ...additional breaking, trimming, branching...
        }
    }
    

    The type length is an interesting validation component, but is a little odd for a modern language. One BIG question I would ask would be what encoding[s] to expect. UTF-8? 7-bit ASCII? Something strange?

    My friends would call the pseudo-code above a hack and tell me to do something like JavaCC, but I have nerdy and impractical friends. 😉

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

Sidebar

Related Questions

I have a mobile app that is using LinqToDatasets to update/insert into a SQL
Say I have a mobile web app written using JQuery Mobile, this app retrieves
I have an app that allows users to win prizes. To win a prize
I have a mobile app that I developed using PhoneGap (and html/css/javascript) and there
I have a simple mobile app in Titanium that I'm using to debug the
I have a small mobile phone app that is acting strangely on the iPhone/Mobile
I have a windows mobile app (mymobiler) that i am trying to install and
I have a mobile app webservice client that connects to a WCF webservice(on my
I have an mobile app that reads a JSON file that is stored on
I have a simple web mobile app that is calculating values in given fields.

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.