Hi all,
Ok so I defined a bean to inject the path of the DIR of the files I want to load. Doing a getFiles() I get the file but now the format of the paths changed.
At this stage jadDir's path if I keep my mouse over the variable is "/WEB-INF/jadjars". Great, but keeping my mouse over file shows "C:/java/apps/...../WEB-INF/jadjars/myjad.jad"Code:public void setJadDir(Resource jadDir) { Assert.isTrue(jadDir.exists()); try { File directory = jadDir.getFile(); File[] files = directory.listFiles(); for (File file : files) { if (!file.isFile()) {
Why did the format now change?
The problem with this is that,
does not work.Code:inputStream = context.getResourceAsStream(file.getPath())
So fine I then tried to substring that long filepath to the short version which does work - eg. I want /WEB-INF/jadjars/myjad.jad cause that works fine.
Guess what, idx == -1, because even though im running a Windows box, the path that context spits out countains forward slashes, while File.separatorChar is a backslash.Code:String contextPath = context.getContextPath(); int idx = contextPath.indexOf(contextPath + File.separatorChar + "WEB-INF");
So I'm screwed.
What now?


Reply With Quote