小编ale*_*x_z的帖子

Java - 使用 getClass().getResource() 的文件路径不起作用

我一直在阅读这里和 Quora 上提出的相同问题,但是,我仍然不明白为什么我无法访问位于“src/main/resources”文件夹中的文件。当我手动指定相对路径“src/main/resources/config/serverConf.xml”时,一切正常

项目结构:

src/main/java/"project related folders"
src/main/resources/config/serverConf.xml
Run Code Online (Sandbox Code Playgroud)

和主类:

public class Main{

    public Main(){
        File file = new File(this.getClass().getResource("config/serverConf.xml").getPath());
        if(file.exists())
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}
Run Code Online (Sandbox Code Playgroud)

java file relative-path

5
推荐指数
1
解决办法
7698
查看次数

如何从F#中的文本文件中仅提取单词?

我试图只从文本文件中提取非常简单的单词:

Please note that you still have an unclaimed iPhone 7. 

We have repeatedly written to you regarding your delivery details. We do not understand why you have not yet confirmed your shipping information so we can send it to your home address. 

Your special price for the brand new  iPhone 7 phone is only £3 with shipping. 

We hope that you'll confirm your information this time. 
Run Code Online (Sandbox Code Playgroud)

我一直在使用这个函数,但似乎它抛出一个异常("方法拆分没有重载匹配"):

let wordSplit (text:string) = 
  text.Split([|' ','\n','\t',',','.','/','\\','|',':',';'|])
  |> Array.toList
Run Code Online (Sandbox Code Playgroud)

string f# text

1
推荐指数
1
解决办法
89
查看次数

标签 统计

f# ×1

file ×1

java ×1

relative-path ×1

string ×1

text ×1