我正在实现服务,该服务应将 csv 文件存储在 Hybris 后台,一天一个文件。 (具体流程完成后加一行)
有什么方法可以重写该文件,因为我仍然得到的只是该文件的新版本。 有没有这方面的文件?恐怕 help.hybris.com 上没有任何内容
File fileForCatalog = ... // I'm able to get that file from backoffice and add a line
Media mediaForFile = MediaManager.getInstance().createMedia(fileForCatalog.getName());
// creates new file
mediaForFile.setFile(fileForCatalog);
mediaForFile.writeReplace(); // creates duplicate
最佳答案
我建议将媒体与媒体服务一起使用。
// Get media, f.e. by code
MediaModel media = mediaService.getMedia("myMediaCode");
InputStream oldInputStream = mediaService.getStreamFromMedia(media);
// add your logic to add a line
InputStream newInputStream = ...;
mediaService.setStreamForMedia(media, newInputStream);
查找Adding characters to beginning and end of InputStream in Java例如如何将你的行添加到输入流。
关于java - Hybris 重写现有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52856660/