Fala. Olha, nao sei se existe alguma funcao ou classe que jah faca isso
que vc quer. Se houver, tb estou interessado em saber. Para resolver esse
problema, costumo fazer da seguinte forma:


////////////////////////////////////////////////

      File file;
      FileReader stream;
      int numChRead;

      file = new File("arquivo.txt");

      //verifies the existence of the input file.
      if ( ! file.exists() || ! file.canRead() ) {
        System.out.println("Either the file " + args[0] + " does not exist or it 
cannot be read");
        System.exit(1);
      }

      try {
        stream = new FileReader(file);
      }
      catch ( FileNotFoundException e ) {
        System.out.println("Something wrong: file does not exist anymore");
        throw new RuntimeException();
      }

      char []input = new char[ ( int ) file.length() + 1 ];

      try {
        numChRead = stream.read( input, 0, ( int ) file.length() );
      }
      catch ( IOException e ) {
        System.out.println("Error reading file arquivo.txt");
        throw new RuntimeException();
      }

      if ( numChRead != file.length() ) {
        System.out.println("Read error");
        throw new RuntimeException();
      }

      try {
        stream.close();
      }
      catch ( IOException e ) {
        System.out.println("Error in handling the file arquivo.txt");
        throw new RuntimeException();
      }

////////////////////////////////////////////////



  Espero que ajude. Ah! Se alguem souber uma forma mais facil, mail us!

  []'s,


     Bruno do Amaral.



  Salvem o Grande Deus Feijao.



On Fri, 24 Jan 2003, Marcelo wrote:

> Caros Javaneses
>
>     Copiei o exemplo Reading Text from a File da p�gina do Java Developers Almanac 
>1.4 (http://javaalmanac.com/egs/java.io/ReadLinesFromFile.html) e estou tentando ler 
>um arquivo texto que contem espa�os entre as palavras, espa�o no inicio do arquivo e 
>espa�o no fim, mas o que acontece � que a string que deveria conter os dados vem SEM 
>os espa�os, eles s�o excluidos! Alguem sabe me dizer porque isso acontece e/ou como 
>resolver????
>
>
> Marcelo Menezes
>
>
>


------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br  -  Sociedade de Usu�rios Java da Sucesu-SP
d�vidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
historico: http://www.mail-archive.com/java-list%40soujava.org.br
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------

Responder a