Hello,
Je cherche à lire un fichier qui est stocké dans un de mes plugin, malheureusement celui-ci n'est pas trouvé lors de l'execution
voici le code utilisé
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 /** The platform-relative path to the resources. */ private static final String RESOURCES_PATH = "platform:/plugin/com.odcgroup.page.common/src/main/resources"; /** The page footer filer. */ private static final String FOOTER_FILE = RESOURCES_PATH + "/" + "tableFooter.xml"; /** * Builds the xsp:logic section and it's children. * * @param context * The WidgetTransformerContext * @param widget * The widget * @param parent * The parent element */ private void buildXspLogic(WidgetTransformerContext context, Widget widget, Element parent) { Element xspLogic = appendElement(context,parent, XSPConstants.XSP_NAMESPACE_URI, XSPConstants.XSP_LOGIC); StringBuffer condition = new StringBuffer(); IPath path = new Path(FOOTER_FILE); IFile file =ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); try { InputStream inputStream = file.getContents(); char c; while((c = (char) inputStream.read()) != -1) { condition.append(c); } inputStream.close(); xspLogic.setTextContent(inputStream.toString()); }catch (Exception ex) { Logger.error("Exception while reading the page footer file ",ex); } }
Partager