如何在文件中保存groovyconsole的输出?

时间:2018-06-14 01:47:34

标签: groovy aem groovy-console

我已经在AEM中安装了groovyconsole,并且我想将一些东西保存在文件中作为输出。

发帖this后,我尝试了:

<DataGrid ItemsSource="{Binding SensorDataTable}" SelectionMode="Extended" SelectionUnit="Cell">
    <DataGrid.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="Background" Value="Yellow"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Converter={StaticResource SensorStatusConverter}}" Value="1">
                    <Setter Property="Background" Value="White"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </DataGrid.CellStyle>
</DataGrid>

我最终得到一个FileNotFoundException。我直接创建文件只是为了确保,但这也没有帮助。

对此有所了解。感谢。

1 个答案:

答案 0 :(得分:0)

我建议您检查以下内容:

  • 您可能没有权限写入指定的文件夹。您应首先尝试写入您绝对具有写访问权限的文件夹。
  • 可能不存在导致output.csv的所有目录,您应该使用File.mkdirs()来确保文件夹树存在,如下所示:
def folderPath = "~/fff/eee/reports"
def folder = new File(folderPath)
def result =folder.mkdirs()

def filePath = "~/fff/eee/reports/output.csv"
File output = new File(filePath)

output.withWriterAppend{ out ->
    out.println 'hello there!'
}
相关问题