Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 拆分(//s+;)不删除空格_Java_String_Split - Fatal编程技术网

Java 拆分(//s+;)不删除空格

Java 拆分(//s+;)不删除空格,java,string,split,Java,String,Split,我需要读取大量文件并将数据插入Ms sql。 有一个文件,看起来文本之间用//t分隔。 Split不起作用,我甚至尝试过使用“//s+”,如下面的代码所示 public void InsetIntoCustomers(final File _file, final Connection _conn) { conn = _conn; try { FileInputStream fs = new FileInputStream(_file);

我需要读取大量文件并将数据插入Ms sql。 有一个文件,看起来文本之间用//t分隔。 Split不起作用,我甚至尝试过使用“//s+”,如下面的代码所示

public void InsetIntoCustomers(final File _file, final Connection _conn)
{
    conn = _conn;
    try
    {

        FileInputStream fs = new FileInputStream(_file);
        DataInputStream in = new DataInputStream(fs);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));

        //String strline contains readline() from BufferedReader
        String strline;

        while((strline = br.readLine()) != null)
        {
            if(!strline.contains("#"))
            {

                String[] test = strline.split("//s+");


                if((tempid = sNet.chkSharednet(_conn, test[0] )) != 0)
                {
                  // do something
                }   
            }
        }

        // close BufferedReader
        br.close();
}
我需要知道在我的字符串[]中,数据放在一个有500k行的文件中的什么位置。但是我的Test[]获取长度1,并且来自readline的所有数据都在位置0上

我用错了吗? 或者我还需要找其他地方吗

//和平号

哈哈-非常感谢你-为什么我自己没看到呢。 是的,ofc。iam在所有其他文件中使用\s+。
但是感谢您指出这一点。

正确的正则表达式是
\\s+
,带有后斜杠而不是前斜杠


您仍然可以尝试使用
\\t

正确的正则表达式是
\\s+
,使用后斜杠而不是前斜杠

您仍然可以尝试使用
\\t