2014-01-12 4 views
-5

У меня есть большой текстовый файл, и я хочу поместить его в ArrayList. Мой текстовый файл содержит # значков в начале, вот текстовые данные.Преобразование строки в Arraylist

#These classes define the style and structure for your dialog, but you should use a DialogFragment as a container for your dialog. The DialogFragment class provides all the controls you need to create your dialog and manage its appearance, instead of calling methods on the Dialog object. 
    #These classes define the style and structure for your dialog, but you should use a DialogFragment as a container for your dialog. The DialogFragment class provides all the controls you need to create your dialog and manage its appearance, instead of calling methods on the Dialog object. 
    #These classes define the style and structure for your dialog, but you should use a DialogFragment as a container for your dialog. The DialogFragment class provides all the controls you need to create your dialog and manage its appearance, instead of calling methods on the Dialog object. 
+1

Использовать 'String.split (" # ")' для преобразования в 'String []' и использовать 'Arrays.asList()' –

+0

Вам нужно попробовать, прежде чем что-то спросить в SO, если вы попытаетесь и не сможете сделайте это самостоятельно, когда пользователи SO попытаются вам помочь. – nKn

+1

Что вы пробовали? Какие методы вы рассмотрели? Что вы узнали, когда искали Google и существующие вопросы здесь? – Simon

ответ

1

Вы можете разбить строку, используя следующий код

String[] divide = string.split("#"); 

, то вы можете использовать

List<String> stringList = new ArrayList<String>(Arrays.asList(divide)); 

Это будет преобразовать массив строк в ArrayList.

Смежные вопросы