Here you can find the source of yaml2List(Charset charset, byte[] data)
Parameter | Description |
---|---|
charset | a parameter |
data | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static List<String> yaml2List(Charset charset, byte[] data) throws IOException
//package com.java2s; /*//from w w w . jav a2 s .c om * Copyright (C) 2012~2013 dinstone<dinstone@163.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; public class Main { /** * @param charset * @param data * @return * @throws IOException */ public static List<String> yaml2List(Charset charset, byte[] data) throws IOException { List<String> list = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(data), charset)); String line = null; while ((line = reader.readLine()) != null) { String[] kvs = line.split(" "); if (kvs.length == 2) { list.add(kvs[1].trim()); } } return list; } }