Java tutorial
//package com.java2s; public class Main { /** * Extracts a GTIN from a GS1-128 (Code 128) formatted bar code. * * @param code * the raw bar code value * @return the extracted GTIN or null if none found */ public static String extractFromCode128(String code) { if (code.length() < 16) { return null; } if (code.startsWith("01") || code.startsWith("02")) { return code.substring(2, 16); } return null; } }