Ler Arquivos de Um Jar Externo

1 resposta
paulo.ubuntu

preciso ler um arquivo que não está no Jar da miha aplicação…e sim num jar externo…

Alguem me da um help ae ???

Abraços Pessoal

1 Resposta

paulo.ubuntu

Achei a Resposta

import java.io.*;
   import java.util.jar.*;

   public class JarRead {
     public static void main (String args[]) 
         throws IOException {
       if (args.length != 2) {
         System.out.println(
           "Please provide a JAR filename and file to read");
         System.exit(-1);
       }
       JarFile jarFile = new JarFile(args[0]);
       JarEntry entry = jarFile.getJarEntry(args[1]);
       InputStream input = jarFile.getInputStream(entry);
       process(input);
       jarFile.close();
     }

     private static void process(InputStream input) 
         throws IOException {
       InputStreamReader isr = 
      new InputStreamReader(input);
       BufferedReader reader = new BufferedReader(isr);
       String line;
       while ((line = reader.readLine()) != null) {
         System.out.println(line);
       }
       reader.close();
     }
   }

Fonte: Site da Sun

Criado 8 de janeiro de 2008
Ultima resposta 8 de jan. de 2008
Respostas 1
Participantes 1