\n em arquivos TXT  XML
Índice dos Fóruns » Java Básico
Autor Mensagem
lance
JavaBaby

Membro desde: 28/03/2006 21:00:44
Mensagens: 81
Offline

Opa galera, blz?
Bom, eu to fazendo um trabalho pra faculdade e preciso salvar um arquivo em txt. Mas quando eu abro no bloco de notas, ele não reconhece o \n. Porém no Wordpad ele reconhece. Como eu faço para o Notepad reconhecer? Existe outro símbolo de quebra de linha?

valeu
Rafael Steil
Administrador
[Avatar]

Membro desde: 31/08/2002 02:35:53
Mensagens: 5984
Localização: São Paulo
Offline

Utilize \r\n

Rafael

"working code attracts people who want to code. Design documents attract people who want to talk about coding - Charles Miller"

http://rafaelsteil.com
http://twitter.com/rafaelsteil
http://www.jforum.net
http://www.flickr.com/photos/rafaelsteil
[Email] [WWW]
peczenyj
Moderador
[Avatar]

Membro desde: 26/03/2006 23:25:37
Mensagens: 3191
Localização: Rio de Janeiro
Offline

isto se deve ao fato do DOS simbolizar o fim de linha por 2 caracteres: CARRIAGE RETURN + LINE FEED

Software applications and operating systems usually represent the newline with one or two control characters:

* Systems based on ASCII or a compatible character set use either LF (Line Feed, 0x0A) or CR (Carriage Return, 0x0D) individually, or CR followed by LF (CR+LF, 0x0D 0x0A).
o LF: Unix and Unix-like systems, Linux, AIX, Xenix, Mac OS X, BeOS, Amiga, RISC OS and others
o CR+LF: CP/M, MP/M, DOS, Microsoft Windows
o CR: Apple II family and Mac OS through version 9
* EBCDIC systems?mainly IBM mainframe systems, including z/OS (OS/390), i5/OS (OS/400)?use NEL (Next Line, 0x15) as the newline character. Note that EBCDIC also has control characters called CR and LF, but the numerical value of LF differs from the one used by ASCII. Additionally, there are some EBCDIC variants that also use NEL but assign a different numeric code to the character.
* OpenVMS uses a record-based file system and stores text files as one record per line. No line terminators are actually stored, but the system can transparently add a terminator to each line when it is retrieved by an application.


Veja mais aqui:
http://en.wikipedia.org/wiki/Newline

http://pacman.blog.br

'Não importa quanto alguém se dedique à tarefa. Ninguém consegue fazer a água da cascata cair para cima.'
[WWW]
lap_junior
JavaTeenager

Membro desde: 09/10/2003 08:42:55
Mensagens: 159
Offline

Melhor ainda use do sistema operacional:



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