Eliminar caracteres estranhos ?[RESOLVIDO]  XML
Índice dos Fóruns » Java Básico
Autor Mensagem
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Estou importando um arquivo em txt, estão aparecendo alguns caracteres estranhos, tem como eliminar ?

Exemplo : Ôªø123.456




Desde já agradeço !

This message was edited 1 time. Last update was at 14/06/2011 07:53:28


"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

mateuscs
JavaTeenager
[Avatar]

Membro desde: 10/05/2011 13:13:14
Mensagens: 179
Offline

Metaleiro

tem como você postar um trecho de seu txt?

Creio que seja definições de arquivo texto para codificação de idiomas.

por exemplo: \u00E7 para Ç
\u00E3 para ã

Mateus C. Santos

Estudante de Ciência da Computação
Programador JAVA
Técnico em Telecomunicações
Cadista
[Email] [MSN]
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Ele está assim :

123.456.789-101234567891011123SP

postei um trecho, na hora que ele importa, aparecem aqueles caracteres, meu arquivo está em UTF8

Obrigado !

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

pedruhenrik
GUJ Master
[Avatar]

Membro desde: 08/05/2008 11:48:36
Mensagens: 1043
Localização: São Paulo - SP
Offline

http://download.oracle.com/javase/6/docs/api/java/text/Normalizer.html

procure por normalizer, talvez ajude.

att,

...tem um plano A e tem um plano B...

http://twitter.com/pedruhenrik
[Email] [MSN]
nel
JWizard
[Avatar]

Membro desde: 01/10/2009 13:51:10
Mensagens: 2364
Offline

Oi!

Isso aqui resolve o seu problema.
Basicamente, é utilizar o método replaceAll com regex da seguinte forma:



Veja o link que lhe passei que exemplifica bem isso.
Abraços!!!

"Se houver a terceira guerra mundial eu não sei como será mas a quarta será com paus e pedras" Albert Einsten.
Vingdel
JavaEvangelist
[Avatar]

Membro desde: 19/11/2006 22:09:57
Mensagens: 358
Localização: Cabo Frio - RJ
Offline

Se teu arquivo não tem caractéres especiais, salve-o como ANSI.

Isso vai resolver.

  • Caso tua dúvida esteja sanada edite tua primeira postagem no tópico e adicione [RESOLVIDO] ao assunto.
  • Poste teu código entre as tags [code] ... [/code].



  • Metaleiro
    Virtual Machine Man
    [Avatar]

    Membro desde: 06/07/2006 10:55:54
    Mensagens: 671
    Localização: São Bernardo do Campo - SP
    Offline

    nel wrote:Oi!

    Isso aqui resolve o seu problema.
    Basicamente, é utilizar o método replaceAll com regex da seguinte forma:



    Veja o link que lhe passei que exemplifica bem isso.
    Abraços!!!


    Funciona bem, mas ele acaba ignorando os espaços em branco do meu arquivo, eu preciso deles, obrigado

    "Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

    Neo :
    -Because is my choice

    mateuscs
    JavaTeenager
    [Avatar]

    Membro desde: 10/05/2011 13:13:14
    Mensagens: 179
    Offline

    Metaleiro

    Como nosso amigo Vingdel mencinou, se seu arquivo não possuir char especial, salve como ansi, e faça o teste.

    Mateus C. Santos

    Estudante de Ciência da Computação
    Programador JAVA
    Técnico em Telecomunicações
    Cadista
    [Email] [MSN]
    Metaleiro
    Virtual Machine Man
    [Avatar]

    Membro desde: 06/07/2006 10:55:54
    Mensagens: 671
    Localização: São Bernardo do Campo - SP
    Offline

    mateuscs wrote:Metaleiro

    Como nosso amigo Vingdel mencinou, se seu arquivo não possuir char especial, salve como ansi, e faça o teste.


    Meu arquivo obrigatoriamente tem que ser em ASCII, agora o único problema são os espaços em branco no arquivo.

    Exemplo :

    18.257.555-4   SSP    133442

    Ele me coloca algo do tipo 18.257.555-4/254

    Se alguém puder me ajudar, agradeço.

    Obrigado a todos

    "Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

    Neo :
    -Because is my choice

    nel
    JWizard
    [Avatar]

    Membro desde: 01/10/2009 13:51:10
    Mensagens: 2364
    Offline

    Metaleiro wrote:
    mateuscs wrote:Metaleiro

    Como nosso amigo Vingdel mencinou, se seu arquivo não possuir char especial, salve como ansi, e faça o teste.


    Meu arquivo obrigatoriamente tem que ser em ASCII, agora o único problema são os espaços em branco no arquivo.

    Exemplo :

    18.257.555-4   SSP    133442

    Ele me coloca algo do tipo 18.257.555-4/254

    Se alguém puder me ajudar, agradeço.

    Obrigado a todos


    Oi! O que seria "meu problema são os espaços em branco" ?
    E o que aquele regex que lhe passei faz que não atende a sua necessidade?
    E por fim, esse "18.257.555-4/254" seria a saida para uma String com contéudo igual a "18.257.555-4 SSP 133442" ?

    Abraços.

    "Se houver a terceira guerra mundial eu não sei como será mas a quarta será com paus e pedras" Albert Einsten.
    Metaleiro
    Virtual Machine Man
    [Avatar]

    Membro desde: 06/07/2006 10:55:54
    Mensagens: 671
    Localização: São Bernardo do Campo - SP
    Offline

    nel wrote:
    Metaleiro wrote:
    mateuscs wrote:Metaleiro

    Como nosso amigo Vingdel mencinou, se seu arquivo não possuir char especial, salve como ansi, e faça o teste.


    Meu arquivo obrigatoriamente tem que ser em ASCII, agora o único problema são os espaços em branco no arquivo.

    Exemplo :

    18.257.555-4   SSP    133442

    Ele me coloca algo do tipo 18.257.555-4/254

    Se alguém puder me ajudar, agradeço.

    Obrigado a todos


    Oi! O que seria "meu problema são os espaços em branco" ?
    E o que aquele regex que lhe passei faz que não atende a sua necessidade?
    E por fim, esse "18.257.555-4/254" seria a saida para uma String com contéudo igual a "18.257.555-4 SSP 133442" ?

    Abraços.


    Não, quando pego minha String ele está substituindo todos os espaços em branco por \240\240\240, ele substitui todos eles por isso, e minha aplicação dá erro, muito obrigado !

    É o único problema que ainda sobra os espaços em branco, quando leio a o arquivo ele substitui por isso.

    "Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

    Neo :
    -Because is my choice

    Metaleiro
    Virtual Machine Man
    [Avatar]

    Membro desde: 06/07/2006 10:55:54
    Mensagens: 671
    Localização: São Bernardo do Campo - SP
    Offline

    POST DUPLICADO

    This message was edited 1 time. Last update was at 13/06/2011 13:36:23


    "Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

    Neo :
    -Because is my choice

    Vingdel
    JavaEvangelist
    [Avatar]

    Membro desde: 19/11/2006 22:09:57
    Mensagens: 358
    Localização: Cabo Frio - RJ
    Offline

    Você já tentou fazer assim?




  • Caso tua dúvida esteja sanada edite tua primeira postagem no tópico e adicione [RESOLVIDO] ao assunto.
  • Poste teu código entre as tags [code] ... [/code].



  • Metaleiro
    Virtual Machine Man
    [Avatar]

    Membro desde: 06/07/2006 10:55:54
    Mensagens: 671
    Localização: São Bernardo do Campo - SP
    Offline

    Vingdel wrote:Você já tentou fazer assim?





    Ocorreu o seguinte :

    The constructor BufferedReader(InputStreamReader) is undefined

    encontrei isso na net :

    BufferedReader

    Obrigado

    "Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

    Neo :
    -Because is my choice

    Vingdel
    JavaEvangelist
    [Avatar]

    Membro desde: 19/11/2006 22:09:57
    Mensagens: 358
    Localização: Cabo Frio - RJ
    Offline

    Você tem que importar o pacote.



    []'s

  • Caso tua dúvida esteja sanada edite tua primeira postagem no tópico e adicione [RESOLVIDO] ao assunto.
  • Poste teu código entre as tags [code] ... [/code].



  •  
    Índice dos Fóruns » Java Básico
    Ir para:   
    Powered by JForum 2.1.8 © JForum Team