All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iheartradio.m3u8.ExtendedM3uScanner Maven / Gradle / Ivy

package com.iheartradio.m3u8;

import java.io.Closeable;
import java.io.InputStream;
import java.util.Locale;
import java.util.Scanner;

public class ExtendedM3uScanner implements Closeable {
    private final Scanner mScanner;
    private final StringBuilder mInput = new StringBuilder();

    private boolean mClosed = false;

    ExtendedM3uScanner(InputStream inputStream, Encoding encoding) {
        mScanner = new Scanner(inputStream, encoding.value).useLocale(Locale.US).useDelimiter("\\r?\\n");
    }

    @Override
    public void close() {
        mScanner.close();
        mClosed = true;
    }

    String getInput() {
        return mInput.toString();
    }

    boolean hasNext() {
        return !mClosed && mScanner.hasNext();
    }

    String next() throws ParseException {
        String line = mScanner.next();
        mInput.append(line);
        return line;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy