Split string into Lines of string - Android java.lang

Android examples for java.lang:String Split

Description

Split string into Lines of string

Demo Code

import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.util.Log;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

    public static List<String> SplitLines(String text) {
        ArrayList<String> list = new ArrayList<String>();
        Scanner scanner = new Scanner(text);
        while (scanner.hasNextLine()) {
            list.add(scanner.nextLine());
        }/*from  w  w w.  j  a v  a2s  .c  o m*/
        scanner.close();
        return list;
    }

}

Related Tutorials