scala中substring使用

微生雨泽
2023-12-01
object Test {
   def main(args: Array[String]) {
      val buf = new StringBuilder;
      // buf += "a"   //添加单个字符用 +=  多个字符用 ++=
      buf ++= "LINESTRING(109.378906132593 24.302867,109.379106202465 24.3028214910803,109.379587767149 24.3026363906891,109.379873079106 24.3025286558287,109.380184115186 24.3024182958702,109.3804311354 24.3023404909118,109.380620788154 24.3022864601758,109.380659672441 24.3022770971361)"
      println( "buf is : " + buf.toString );
  		
	  println("buf:"+ buf.substring(11,buf.length - 1))
   
   }
}

结果:

buf is : LINESTRING(109.378906132593 24.302867,109.379106202465 24.3028214910803,109.379587767149 24.3026363906891,109.379873079106 24.3025286558287,109.380184115186 24.3024182958702,109.3804311354 24.3023404909118,109.380620788154 24.3022864601758,109.380659672441 24.3022770971361)
buf:109.378906132593 24.302867,109.379106202465 24.3028214910803,109.379587767149 24.3026363906891,109.379873079106 24.3025286558287,109.380184115186 24.3024182958702,109.3804311354 24.3023404909118,109.380620788154 24.3022864601758,109.380659672441 24.3022770971361

 

 类似资料: