我正在尝试从包含\n
. 结果,这些字符被写为换行符。当我试图回读它时,
我正在使用FileInputStream
,InputStreamReader
和BufferedReader
. 但是,当我阅读每一行时,读者会注意到换行并将其视为行尾。我真正想要的是阅读到行尾,保留换行符。我试图看看我是否真的可以写字符\
以及n
在创建文件时,但无论我尝试什么,如果不变成正常的换行符,它们就不会写。
如何在保留换行符的同时读取此文件?
编辑:为澄清起见,这是我正在阅读的数据示例。可以看出,每行所说Args
的都在自己的行上。这是我想忽略的换行符。我希望每个命令(例如 dt、e、b、c、o 等)都有自己的行。理想情况下看起来像这样:
o Desc: Opens a file or folder#Args: [<handle or path>] -- the path of the file or folder#(<file name>) -- the name of the file to open. Omit if you are opening a folder.
#
我已经用符号替换了我希望忽略的换行符。但是,当我将文件读回到我的程序中时,我希望它是这样的,如果我System.out.println();
换行,被替换的换行符#
将正确显示。
dt Desc: Toggles the state of debug mode.
e Desc: Exits QuiConsole
b Desc: Goes to the specified webpages.
Args: [<URLs>] -- the URLs of the webpages to visit, separated by spaces
c Desc: Clears the console window.
o Desc: Opens a file or folder
Args: [<handle or path>] -- the path of the file or folder
(<file name>) -- the name of the file to open. Omit if you are opening a folder
l Desc: Searches the web
Args: [<query>] -- the query to search for
h Desc: Displays a list of all the current handles.
Args: (<handle names>) -- displays information for only the specified handles.
info Desc: Displays information about QuiConsole
help Desc: Displays a list of all commands, their descriptions and their arguments, if any exist.
Args: (<command names>) -- Displays information for the specified command only. Ignores any invalid command names.
s Desc: Shuts down, restarts, hibernates or logs off the computer.
Args: [s,r,h,l] -- shuts down, restarts, hibernates or logs off the computer respectively.
(<integer value>) -- the number of seconds to delay the action.
dh Desc: Deletes all handles
Args: (<handle names>) -- deletes only the specified handles
r Desc: Runs the specified program
Args: [<names>] -- the names of the programs to run. Separate programs by a space.
wa Desc: Displays the answer from Wolfram|Alpha
Args: [<query>] -- the query to send to Wolfram|Alpha
ch Desc: Modifies a handle
Args: [<handle names>] -- the handle to change
[<new value>] -- the new value to assign to the handle
ah Desc: Adds the specified handles.
Args: [handle] -- name of the handle.
[value] -- value for the handle
ds Desc: Displays the state of debug mode.
dhist Desc: Deletes command history