axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chitgoks <chitg...@gmail.com>
Subject Re: Read/Write file with absolute path
Date Mon, 03 Mar 2008 10:31:22 GMT
janfry, getResource and getResourceAsStream dont work with physical files,
those methods can be used if the files to be read are within the same jar
file as the class that's calling it

why dont you try using / instead of \\? though they both are the same.
if it says file not found then the file's not there

On Mon, Mar 3, 2008 at 6:28 PM, Javier V <janfry6@hotmail.com> wrote:

>  Hi.
>
> This must be a newbie question but I haven't found how to resolve it.
>
> I'm using Windows, Tomcat 5.5 and Axis 1.3.
>
> I want to read (and write) files that are in directories not included in
> the classpath.
>
> The following method to read a file and returning the contents into a
> String:
>
>     public static String readFile2String(String file) throws Exception {
>         String content = null;
>         FileInputStream fis = null;
>         try {
>             fis = new FileInputStream(file);
>             int x = fis.available();
>             byte b[] = new byte[x];
>             fis.read(b);
>             content = new String(b);
>         } finally {
>             if (fis != null) {
>                 fis.close();
>             }
>         }
>         return content;
>     }
>
> works with these calling lines in a standalone program:
>
>     public static void main(String[] args) throws Exception {
>         System.out.println("FILE CONTENTS=" +
> readFile2String("W:\\tests\\data\\fich00.dat"));
>     }
>
> However, when executed
>
>    readFile2String("W:\\tests\\data\\fich00.dat")
>
> within the web service, it generates "java.io.FileNotFoundException".
>
> Must I configure anything in Tomcat and/or Axis2 to access any file or
> directory?
>
> NOTE: I do NOT want to include those files into "lib" or "classes"
> directory, and how the files are not
> in the classpath, getClassLoader().getResource() o getResourceAsStream I
> know doesn't work.
>
> Thanks in advance,
>
> Janfry
>
>
> ------------------------------
> Sigue de cerca las últimas tendencias y lo que más rompe MSN Vídeo<http://video.msn.com/video.aspx?mkt=es-es>
>



-- 
Website: http://chitgoks.freehostia.com
Java Casino Games: http://chitgoks.tripod.com
My Blogs:
http://chitgoks.blogspot.com
http://wuhtevah.blogspot.com

Mime
View raw message