groovy java split string

Created by Tung NGUYEN on 2017-05-03 01:39:24
Last modified on 2017-05-03 01:39:24

//String str1 = "IPR031887 Serologically defined colon cancer antigen 8"
String str1 = "LTPOS"
String[] entry = str1.split(" ", 2)
if (entry.size() == 1) 
  println entry[0]
else {
println  entry[0]
println  entry[1]
}

String str = "name1, name2, name3, name4";
String[] parts = str.split(", ", 2);
String string1 = parts[0];
String string2 = parts[1];

System.out.println(string1);  // prints name1
System.out.println(string2);  // prints name2, name3, name4

import java.net.*
import java.io.*
URL oracle = new URL("ftp://ftp.ebi.ac.uk/pub/databases/interpro/entry.list")
BufferedReader br = new BufferedReader(new InputStreamReader(oracle.openStream()))
String inputLine

while ((inputLine = br.readLine()) != null)
inputLine
br.close()

Category: Todos
Tags: 6

© 2013 - 2026. Tung NGUYEN. Using CI version: 3.0.2 | Page rendered in 0.0073 seconds.