Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.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
使用scala时在play framework中保存外部文件的位置_Scala_Playframework - Fatal编程技术网

使用scala时在play framework中保存外部文件的位置

使用scala时在play framework中保存外部文件的位置,scala,playframework,Scala,Playframework,play framework中的外部文件应保存在何处?我尝试将它添加到conf文件夹中,但没有成功。然后我把它添加到项目文件夹中,它也不起作用。我在build.scala中定义了依赖项,但这不起作用。该文件应该在文件输入流中使用。类路径中将提供conf的内容,包括子目录。然后您可以在应用程序中访问它 例如,如果您在conf中创建一个resources目录并在其中放置一个文件: -- app -- bin -- conf - resources - myfile ...

play framework中的外部文件应保存在何处?我尝试将它添加到
conf
文件夹中,但没有成功。然后我把它添加到项目文件夹中,它也不起作用。我在
build.scala
中定义了依赖项,但这不起作用。该文件应该在文件输入流中使用。

类路径中将提供
conf
的内容,包括子目录。然后您可以在应用程序中访问它

例如,如果您在
conf
中创建一个
resources
目录并在其中放置一个文件:

 -- app
 -- bin
 -- conf
   - resources
       - myfile
 ...
然后您可以通过以下方式获取内容:

val stream = getClass.getResourceAsStream("/resources/myfile")
val content = io.Source.fromInputStream(stream).mkString
通过转到
/target/scala xx/classes/
,您可以检查复制的内容以及在类路径上可用的内容