\n em arquivos TXT

3 respostas
Rafael_Steil

Utilize \r\n

Rafael

3 Respostas

peczenyj

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 systemsmainly 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:

L

Melhor ainda use do sistema operacional:

String novaLinha = System.getProperty( "line.separator" ); String texto = "linha 1" + novaLinha + "linha 2";

flw

L

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 :wink:

Criado 4 de junho de 2006
Ultima resposta 4 de jun. de 2006
Respostas 3
Participantes 4