Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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 如何限制使用Scala显示的字符串中的字符数_Java_Html_Scala - Fatal编程技术网

Java 如何限制使用Scala显示的字符串中的字符数

Java 如何限制使用Scala显示的字符串中的字符数,java,html,scala,Java,Html,Scala,我对Scala还比较陌生,不太懂语法,所以我想寻求一些指导。我在一个ArrayList中读取一个网页,并以表格格式显示信息。以下是我的页面中的html示例: <table> <thead> <tr>...</tr> </thead> <tbody> @for(info <- Info.all) { <tr> <td>@info.name

我对Scala还比较陌生,不太懂语法,所以我想寻求一些指导。我在一个ArrayList中读取一个网页,并以表格格式显示信息。以下是我的页面中的html示例:

<table>
  <thead>
    <tr>...</tr>
  </thead>
  <tbody>
    @for(info <- Info.all) {
      <tr>
          <td>@info.name</td>
          <td>@info.id</td>
          <td>@info.birthdate</td>
          <td>@info.notes</td>
      </tr>
    }
  </tbody>
</table>

...
@对于(信息这个怎么样

@info.notes.take(12)
或者像这样的java风格:

@info.notes.substring(0, 12)
这个怎么样

@info.notes.take(12)
或者像这样的java风格:

@info.notes.substring(0, 12)

奇迹!您提供的第一个选项非常有效!谢谢!
take
更可取,因为如果
notes
少于12个字符,则
substring
将引发异常。我尝试了
substring
选项,但确实得到了一个异常。
take
方法完成了我的搜索。谢谢信息!奇迹!您提供的第一个选项非常有效!谢谢!
take
更可取,因为如果
notes
少于12个字符,则
substring
将引发异常。我尝试了
substring
选项,但确实得到了一个异常。
take
方法完成了我所寻找的任务。谢谢你的信息!