Retirar quebra de linha de String ?[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: 716
Localização: São Bernardo do Campo - SP
Offline

Alguém saberia como retirar a quebra de Linha de uma String ?

Estou passando para uma página JSP.



A JSP



Desde já agradeço !

This message was edited 1 time. Last update was at 19/08/2011 09:17:14


"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: 716
Localização: São Bernardo do Campo - SP
Offline

Encontrei exemplos como esse :


http://www.arquivodecodigos.net/dicas/java-remover-quebras-de-linhas-de-uma-string-338.html


Se alguém puder me ajudar

"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: 2963
Offline

Oi!

Tente isso:


"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: 716
Localização: São Bernardo do Campo - SP
Offline

nel wrote:Oi!

Tente isso:




Obrigado, porém não funcionou

"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: 2963
Offline

Poste o trecho de código que deseja executar tal ação com a String preenchida, por favor.
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: 716
Localização: São Bernardo do Campo - SP
Offline


"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: 2963
Offline

Metaleiro wrote:


Estamos falando de scriplets? Ai é mais complicado mesmo, porque não sei se ele pega algo da variavél de sistema "line.separator".
Veja se isso lhe ajuda:



"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: 716
Localização: São Bernardo do Campo - SP
Offline

Também não funcionou mas agradeço


"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

JM4X
JavaChild
[Avatar]

Membro desde: 01/07/2010 14:16:04
Mensagens: 137
Localização: São Paulo
Offline

não manjo de scriplets, mas tenta fazer um teste.

pegue um texto conhecido com quebra de linha, você deve saber a posição exata da quebra de linha

use o texto.charAt(x) onde x é a posição da quebra de linha.

faça um cast do resultado:
int i = (int) texto.charAt(x);

assim você vai saber codigo ascii do caracter de quebra de linha, daí é só utilizar o replaceAll...

sakou?

This message was edited 1 time. Last update was at 18/08/2011 18:41:23

[MSN]
JM4X
JavaChild
[Avatar]

Membro desde: 01/07/2010 14:16:04
Mensagens: 137
Localização: São Paulo
Offline

.

This message was edited 1 time. Last update was at 18/08/2011 18:48:33

[MSN]
Metaleiro
Virtual Machine Man
[Avatar]

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

Estou usando :

& n b s p

Porém ele evita a quebra de linha mas imprime alguns caracteres estranhos  Â Â Â Â Â Â Â Â Â Â Â Â Â Â :


QHB15GVBNLJ   4FMQK9HQIEG     48UQIPCWW32                                      Â


Se alguém puder me ajudar, desde já agradeço !

"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: 716
Localização: São Bernardo do Campo - SP
Offline

Usei um Ext.urlEncode





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

Metaleiro
Virtual Machine Man
[Avatar]

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

Também usei isso no JSP:


"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

aureliolima
JavaChild
[Avatar]

Membro desde: 04/03/2009 15:02:02
Mensagens: 123
Offline

Adaptei um método que tinha feito com as sugestões deste post e funcionou, para ignorar quebras de linhas ao gravar em um arquivo.txt:

Estava usando apenas o ao invés de .
Acrescentei tb o .


Atenciosamente.

Aurélio Camara Lima

Desenvolvimento de Sistemas Web
Passo Fundo / RS
Blog: aureliolima.wordpress.com
[Email] [MSN]
 
Índice dos Fóruns » Java Básico
Ir para:   
Powered by JForum 2.1.8 © JForum Team