If /Application/testdata/ntd.txt
is the path of your txt file then below code will work (what i guess is your requirement).
public static void main(String[] args) throws IOException
{
String content=null;
File folder = new File("/Application/testdata/ntd.txt");
content = FileUtils.readFileToString(folder)+"\n";
System.out.println(content);
int outside=Integer.parseInt(content.substring(0, content.indexOf("[")).trim());
System.out.println("int val: "outside);
String remainingString=content.substring(content.indexOf("["), content.lastIndexOf("]")+1);
System.out.println("String value: "remainingString);
}
OUTPUT:
50 [40,-13,-6,-7,-4] [28,-40,45,-29,37] [-43,19,-24,-9,-45] [26,-41,-28,-16,44]
int val: 50
String value: [40,-13,-6,-7,-4] [28,-40,45,-29,37] [-43,19,-24,-9,-45] [26,-41,-28,-16,44]
I used apache commons for file read. If you waNT to break remainingString
further then split it according to SPACE character.