split fails

package com.cobra.control.controls;

publicclass Port{

public String name, module;

publicint module_port_index;

publicboolean module_dir =false;// f=in, t=out

publicdouble value = 0.0;

public Port(){

}

public Port(String n){

String s[] = n.split(".");

if (s.length == 2){

module = s[0];

if ("out".equals(s[1].toLowerCase().substring(0, 3))){

module_dir =true;

}elseif ("in".equals(s[1].toLowerCase().substring(0, 2))){

module_dir =false;

}

int i = s[1].indexOf("["), j = s[1].indexOf("]");

module_port_index = Integer.parseInt(s[1].substring(i + 1, j));

}else System.out.println("Illegal wire-port association");

}

}

I have written some simulation-code but the connections don't seem to work properly. I have narraowed the problem down to the split statement in the above code....

when i call the contructor new Port("mod1.out[0]") it does'nt split the sptring at the desired token...

Any solutions to this problem?

[2270 byte] By [edwinfvanoostroma] at [2007-10-3 1:21:23]
# 1
A full stop has special meaning in a regex, you need String s[] = n.split("\\.");
sabre150a at 2007-7-14 18:18:36 > top of Java-index,Java Essentials,Java Programming...