Java中的\ r回车符和\ f换页符是什么意思? [英] What is the meaning \r carriage return and \f form feed in Java?

查看:87
本文介绍了Java中的\ r回车符和\ f换页符是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java中 \ r 回车和/f 换页符是什么意思?谁能举一个简短的例子说明何时必须使用这些类型的符号?

What is the meaning of \r carriage return and /f form feed in Java? Can anyone give a small example of when we have to use these types of symbols?

System.out.println("hello world \r rafter \n nafter \f fafter");

我不知道上面是什么.

我得到的输出是:

hello world 
 r-after 
 n-after  f-after

我以 \ r 作为新行,并以 \ n 作为新行,并以 \ f 出现一个框.

I got \r as new line and \n for new line and with \f a box appears for me.

推荐答案

在现代应用程序中,您很少(单独)使用它们中的任何一个.

You rarely use either of them (in isolation) in modern applications.

\ r (回车)听起来像 if 您熟悉老式的手动打字机:它将托架"(送入纸张的纸卷)移回该行的开头.在终端(或类似终端)上,它将输出点移回该行的开头,而无需向下移动(通常).

\r (carriage return) is what it sounds like if you're familiar with old-fashioned manual typewriters: It moves the "carriage" (the roll the paper is fed through) back to the beginning of the line. On a terminal (or similar), it moves the output point back to the beginning of the line, without moving down a line (usually).

\ f 是(如您所说的) formfeed ,它告诉老式打印机开始新页面.在计算机文档中,有时用于指示分页符.

\f is (as you said) a formfeed, it tells old-fashioned printers to start a new page. In computer documents, it's sometimes used to indicate a page break.

整理一下内容,还有换行符(也称为换行符"): \ n .这意味着向下移动".在某些航站楼中,它只是沿一条线向下移动而无需返回回车;在其他人身上,两者都有.

Rounding things out, there's also line feed (aka "newline"): \n. This means "move down a line." In some terminals, it just moves down a line without doing a carriage return; on others, it does both.

\ n (LF,换行符)是* nix和派生操作系统上的标准文本文件换行符. \ r \ n (CRLF)是DOS和Windows上标准的文本文件换行符.过去, \ r (单独)是Mac OS X(* nix派生的)之前的Mac上文本文件的标准换行符.

\n (LF, newline) is the standard text file line break on *nix and derived operating systems. \r\n (CRLF) is the standard text file line break on DOS and Windows. Back in the day, \r (on its own) was the standard line break in text files on the Mac, prior to Mac OS X (which is *nix-derived).

这篇关于Java中的\ r回车符和\ f换页符是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆