Here you can find the source of toArray(String s)
public static double[] toArray(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static double[] toArray(String s) { double[] ret = new double[s.length() * 8]; feedString(s, ret);/*from w ww.j ava 2 s. co m*/ return ret; } public static void feedString(String s, double[] networkLayer) { feedString(s, networkLayer, 0); } public static void feedString(String s, double[] networkLayer, int startIndex) { for (int i = 0; i < s.length(); i++) { feedChar(s.charAt(i), networkLayer, startIndex + i * 8); } } public static void feedChar(char c, double[] networkLayer) { feedChar(c, networkLayer, 0); } public static void feedChar(char c, double[] networkLayer, int startIndex) { int num = (int) c; for (int i = 0; i < 8; i++) { networkLayer[8 - i - 1 + startIndex] = num % 2; num /= 2; } } }