add: search for scripts and posts
This commit is contained in:
297
app/src/main/assets/docs/files.html
Normal file
297
app/src/main/assets/docs/files.html
Normal file
@@ -0,0 +1,297 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Files | Auto.js 2.0.16 文档</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
<link rel="stylesheet" href="assets/sh.css">
|
||||
<link rel="canonical" href="https://nodejs.org/api/files.html">
|
||||
</head>
|
||||
<body class="alt apidoc" id="api-section-files">
|
||||
<div id="content" class="clearfix">
|
||||
<div id="column2" class="interior">
|
||||
<div id="intro" class="interior">
|
||||
<a href="/" title="返回首页">
|
||||
Auto.js
|
||||
</a>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a class="nav-documentation" href="documentation.html">关于本文档</a></li>
|
||||
<li><a class="nav-synopsis" href="synopsis.html">如何阅读本文档</a></li>
|
||||
</ul>
|
||||
<div class="line"></div>
|
||||
|
||||
<ul>
|
||||
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
|
||||
<li><a class="nav-qa" href="qa.html">Q&A - 常见问题</a></li>
|
||||
<li><a class="nav-globals" href="globals.html">Globals - 一般全局函数</a></li>
|
||||
<li><a class="nav-widgets-based-automation" href="widgets-based-automation.html">WidgetsBasedAutomation - 基于控件的触摸模拟</a></li>
|
||||
<li><a class="nav-coordinates-based-automation" href="coordinates-based-automation.html">CoordinatesBasedAutomation - 基于坐标的触摸模拟</a></li>
|
||||
<li><a class="nav-images" href="images.html">Images - 图片与图色处理</a></li>
|
||||
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
|
||||
<li><a class="nav-events" href="events.html">Events - 事件与监听</a></li>
|
||||
<li><a class="nav-timers" href="timers.html">Timers - 定时器</a></li>
|
||||
<li><a class="nav-shell" href="shell.html">Shell - Shell命令</a></li>
|
||||
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
|
||||
<li><a class="nav-files active" href="files.html">Files - 文件系统</a></li>
|
||||
<li><a class="nav-app" href="app.html">App - 应用</a></li>
|
||||
<li><a class="nav-engines" href="engines.html">Engines - 脚本引擎</a></li>
|
||||
<li><a class="nav-modules" href="modules.html">Modules - 模块</a></li>
|
||||
<li><a class="nav-work-with-java" href="work-with-java.html">Work with Java - 调用Java API</a></li>
|
||||
</ul>
|
||||
<div class="line"></div>
|
||||
|
||||
<ul>
|
||||
<li><a class="nav-https-github-com-hyb1996-NoRootScriptDroid" href="https://github.com/hyb1996/NoRootScriptDroid">GitHub项目 & Issue提交</a></li>
|
||||
<li><a class="nav-http-autojs-org" href="http://autojs.org">Auto.js交流社区</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="column1" data-id="files" class="interior">
|
||||
<header>
|
||||
<h1>Auto.js 2.0.16 文档</h1>
|
||||
<div id="gtoc">
|
||||
<p>
|
||||
<a href="index.html" name="toc">索引</a> |
|
||||
<a href="all.html">查看全部</a>
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
</header>
|
||||
|
||||
<div id="toc">
|
||||
<h2>目录</h2>
|
||||
<ul>
|
||||
<li><span class="stability_2"><a href="#files_files">Files</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#files_files_isfile_path">files.isFile(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_isdir_path">files.isDir(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_isemptydir_path">files.isEmptyDir(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_join_parent_child">files.join(parent, child)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_create_path">files.create(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_createifnotexists_path">files.createIfNotExists(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_exists_path">files.exists(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_ensuredir_path">files.ensureDir(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_read_path_encoding_utf_8">files.read(path[, encoding = "utf-8"])</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_write_path_text_encoding_utf_8">files.write(path, text[, encoding = "utf-8"])</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_copy_frompath_topath">files.copy(fromPath, toPath)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_move_frompath_topath">files.move(fromPath, toPath)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_rename_path_newname">files.rename(path, newName)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_renamewithoutextension_path_newname">files.renameWithoutExtension(path, newName)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_getname_path">files.getName(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_getnamewithoutextension_path">files.getNameWithoutExtension(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_getextension_path">files.getExtension(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_remove_path">files.remove(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_removedir_path">files.removeDir(path)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_getsdcardpath">files.getSdcardPath()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_files_listdir_path_filter">files.listDir(path[, filter])</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_open_path_mode_r_encoding_utf_8_buffersize_8192">open(path[, mode = "r", encoding = "utf-8", bufferSize = 8192])</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_undefined"><a href="#files_readabletextfile">ReadableTextFile</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#files_readabletextfile_read">ReadableTextFile.read()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_readabletextfile_read_maxcount">ReadableTextFile.read(maxCount)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_readabletextfile_readline">ReadableTextFile.readline()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_readabletextfile_readlines">ReadableTextFile.readlines()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_close">close()</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile">PWritableTextFile</a></span><ul>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile_write_text">PWritableTextFile.write(text)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile_writeline_line">PWritableTextFile.writeline(line)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile_writelines_lines">PWritableTextFile.writelines(lines)</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile_flush">PWritableTextFile.flush()</a></span></li>
|
||||
<li><span class="stability_undefined"><a href="#files_pwritabletextfile_close">PWritableTextFile.close()</a></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="apicontent">
|
||||
<h1>Files<span><a class="mark" href="#files_files" id="files_files">#</a></span></h1>
|
||||
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><p>files模块提供了一些常见的文件处理,包括文件读写、移动、复制、删掉等。</p>
|
||||
<h2>files.isFile(path)<span><a class="mark" href="#files_files_isfile_path" id="files_files_isfile_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回路径path是否是文件。</p>
|
||||
<h2>files.isDir(path)<span><a class="mark" href="#files_files_isdir_path" id="files_files_isdir_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回路径path是否是文件夹。</p>
|
||||
<h2>files.isEmptyDir(path)<span><a class="mark" href="#files_files_isemptydir_path" id="files_files_isemptydir_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回文件夹path是否为空文件夹。如果该路径并非文件夹,则直接返回false。</p>
|
||||
<h2>files.join(parent, child)<span><a class="mark" href="#files_files_join_parent_child" id="files_files_join_parent_child">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>parent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 父目录路径</li>
|
||||
<li><code>child</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 子路径</li>
|
||||
</ul>
|
||||
</div><p>连接两个路径并返回,例如<code>files.join("/sdcard/", "1.txt")</code>返回"/sdcard/1.txt"。</p>
|
||||
<h2>files.create(path)<span><a class="mark" href="#files_files_create_path" id="files_files_create_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>创建一个文件并返回是否创建成功。</p>
|
||||
<h2>files.createIfNotExists(path)<span><a class="mark" href="#files_files_createifnotexists_path" id="files_files_createifnotexists_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>创建一个文件并返回是否创建成功。</p>
|
||||
<h2>files.exists(path)<span><a class="mark" href="#files_files_exists_path" id="files_files_exists_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回在路径path处的文件是否存在。</p>
|
||||
<h2>files.ensureDir(path)<span><a class="mark" href="#files_files_ensuredir_path" id="files_files_ensuredir_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>确保路径path所在的文件夹存在。</p>
|
||||
<p>例如对于路径"/sdcard/Download/ABC/1.txt",如果/Download/文件夹不存在,则会先创建Download,再创建ABC文件夹。</p>
|
||||
<h2>files.read(path[, encoding = "utf-8"])<span><a class="mark" href="#files_files_read_path_encoding_utf_8" id="files_files_read_path_encoding_utf_8">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
<li><code>encoding</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 字符编码</li>
|
||||
</ul>
|
||||
</div><p>读取文件path的所有内容并返回。</p>
|
||||
<h2>files.write(path, text[, encoding = "utf-8"])<span><a class="mark" href="#files_files_write_path_text_encoding_utf_8" id="files_files_write_path_text_encoding_utf_8">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
<li><code>text</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要写入的文本内容</li>
|
||||
<li><code>encoding</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 字符编码</li>
|
||||
</ul>
|
||||
</div><p>把text写入到文件path中。如果文件存在则覆盖,不存在则创建。</p>
|
||||
<h2>files.copy(fromPath, toPath)<span><a class="mark" href="#files_files_copy_frompath_topath" id="files_files_copy_frompath_topath">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>fromPath</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要复制的原文件路径</li>
|
||||
<li><code>toPath</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 复制到的文件路径</li>
|
||||
</ul>
|
||||
</div><p>复制文件。例如<code>files.copy("/sdcard/1.txt", "/sdcard/Download/1.txt")</code>。</p>
|
||||
<h2>files.move(fromPath, toPath)<span><a class="mark" href="#files_files_move_frompath_topath" id="files_files_move_frompath_topath">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>fromPath</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要移动的原文件路径</li>
|
||||
<li><code>toPath</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 移动到的文件路径</li>
|
||||
</ul>
|
||||
</div><p>移动文件,返回是否移动成功。例如<code>files.move("/sdcard/1.txt", "/sdcard/Download/1.txt")</code>会把1.txt文件从sd卡根目录移动到Download文件夹。</p>
|
||||
<h2>files.rename(path, newName)<span><a class="mark" href="#files_files_rename_path_newname" id="files_files_rename_path_newname">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要重命名的原文件路径</li>
|
||||
<li><code>newName</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要重命名的新文件名</li>
|
||||
</ul>
|
||||
</div><p>重命名文件,并返回是否重命名成功。例如<code>files.rename("/sdcard/1.txt", "2.txt")</code>。</p>
|
||||
<h2>files.renameWithoutExtension(path, newName)<span><a class="mark" href="#files_files_renamewithoutextension_path_newname" id="files_files_renamewithoutextension_path_newname">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要重命名的原文件路径</li>
|
||||
<li><code>newName</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 要重命名的新文件名</li>
|
||||
</ul>
|
||||
</div><p>重命名文件,不包含拓展名,并返回是否重命名成功。例如<code>files.rename("/sdcard/1.txt", "2")</code>会把1.txt重命名为2.txt。</p>
|
||||
<h2>files.getName(path)<span><a class="mark" href="#files_files_getname_path" id="files_files_getname_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回文件的文件名。例如<code>files.getName("/sdcard/1.txt")</code>返回"1.txt"。</p>
|
||||
<h2>files.getNameWithoutExtension(path)<span><a class="mark" href="#files_files_getnamewithoutextension_path" id="files_files_getnamewithoutextension_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回不含拓展名的文件的文件名。例如<code>files.getName("/sdcard/1.txt")</code>返回"1"。</p>
|
||||
<h2>files.getExtension(path)<span><a class="mark" href="#files_files_getextension_path" id="files_files_getextension_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>返回文件的拓展名。例如<code>files.getExtension("/sdcard/1.txt")</code>返回"txt"。</p>
|
||||
<h2>files.remove(path)<span><a class="mark" href="#files_files_remove_path" id="files_files_remove_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>删除文件或<strong>空文件夹</strong>,返回是否删除成功。</p>
|
||||
<h2>files.removeDir(path)<span><a class="mark" href="#files_files_removedir_path" id="files_files_removedir_path">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
</ul>
|
||||
</div><p>删除文件夹,如果文件夹不为空,则删除该文件夹的所有内容再删除该文件夹,返回是否全部删除成功。</p>
|
||||
<h2>files.getSdcardPath()<span><a class="mark" href="#files_files_getsdcardpath" id="files_files_getsdcardpath">#</a></span></h2>
|
||||
<p>返回SD卡路径。所谓SD卡,即外部存储器。</p>
|
||||
<h2>files.listDir(path[, filter])<span><a class="mark" href="#files_files_listdir_path_filter" id="files_files_listdir_path_filter">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 路径</li>
|
||||
<li><code>filter</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 过滤函数,可选。接收一个String参数(文件名),返回一个Boolean值。</li>
|
||||
</ul>
|
||||
</div><p>列出文件夹path下的满足条件的文件和文件夹的名称的数组。如果不加filter参数,则返回所有文件和文件夹。</p>
|
||||
<p>例如,获取sdcard目录下的txt文件为</p>
|
||||
<pre><code>var txtFiles = files.listDir("/sdcard/", function(name){
|
||||
return name.endsWith(".txt") && files.isFile("/sdcard/" + name);
|
||||
});
|
||||
</code></pre><h2>open(path[, mode = "r", encoding = "utf-8", bufferSize = 8192])<span><a class="mark" href="#files_open_path_mode_r_encoding_utf_8_buffersize_8192" id="files_open_path_mode_r_encoding_utf_8_buffersize_8192">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 文件路径,例如"/sdcard/1.txt"。</li>
|
||||
<li><code>mode</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 文件打开模式,包括:<ul>
|
||||
<li>"r": 只读模式。该模式下只能对文件执行<strong>文本</strong>读取操作。</li>
|
||||
<li>"w": 只写模式。该模式下只能对文件执行<strong>文本</strong>覆盖写入操作。</li>
|
||||
<li>"a": 附加模式。该模式下将会把写入的文本附加到文件末尾。<br>目前暂不支持二进制模式,随机读写模式。</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>encoding</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 字符编码。</li>
|
||||
<li><code>bufferSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><Number></a> 文件读写的缓冲区大小。</li>
|
||||
</ul>
|
||||
</div><p>打开一个文件。根据打开模式返回不同的文件对象。包括:</p>
|
||||
<ul>
|
||||
<li>"r": 返回一个ReadableTextFile对象。</li>
|
||||
<li>"w", "a": 返回一个WritableTextFile对象。</li>
|
||||
</ul>
|
||||
<p>对于"w"模式,如果文件并不存在,则会创建一个,已存在则会清空该文件内容;其他模式文件不存在会抛出FileNotFoundException。</p>
|
||||
<h1>ReadableTextFile<span><a class="mark" href="#files_readabletextfile" id="files_readabletextfile">#</a></span></h1>
|
||||
<p>可读文件对象。</p>
|
||||
<h2>ReadableTextFile.read()<span><a class="mark" href="#files_readabletextfile_read" id="files_readabletextfile_read">#</a></span></h2>
|
||||
<p>返回该文件剩余的所有内容的字符串。</p>
|
||||
<h2>ReadableTextFile.read(maxCount)<span><a class="mark" href="#files_readabletextfile_read_maxcount" id="files_readabletextfile_read_maxcount">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>maxCount</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><Number></a> 最大读取的字符数量</li>
|
||||
</ul>
|
||||
</div><p>读取该文件接下来最长为maxCount的字符串并返回。即使文件剩余内容不足maxCount也不会出错。</p>
|
||||
<h2>ReadableTextFile.readline()<span><a class="mark" href="#files_readabletextfile_readline" id="files_readabletextfile_readline">#</a></span></h2>
|
||||
<p>读取一行并返回(不包含换行符)。</p>
|
||||
<h2>ReadableTextFile.readlines()<span><a class="mark" href="#files_readabletextfile_readlines" id="files_readabletextfile_readlines">#</a></span></h2>
|
||||
<p>读取剩余的所有行,并返回它们按顺序组成的字符串数组。</p>
|
||||
<h2>close()<span><a class="mark" href="#files_close" id="files_close">#</a></span></h2>
|
||||
<p>关闭该文件。</p>
|
||||
<p><strong>打开一个文件不再使用时务必关闭</strong></p>
|
||||
<h1>PWritableTextFile<span><a class="mark" href="#files_pwritabletextfile" id="files_pwritabletextfile">#</a></span></h1>
|
||||
<p>可写文件对象。</p>
|
||||
<h2>PWritableTextFile.write(text)<span><a class="mark" href="#files_pwritabletextfile_write_text" id="files_pwritabletextfile_write_text">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>text</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 文本</li>
|
||||
</ul>
|
||||
</div><p>把文本内容text写入到文件中。</p>
|
||||
<h2>PWritableTextFile.writeline(line)<span><a class="mark" href="#files_pwritabletextfile_writeline_line" id="files_pwritabletextfile_writeline_line">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>text</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 文本</li>
|
||||
</ul>
|
||||
</div><p>把文本line写入到文件中并写入一个换行符。</p>
|
||||
<h2>PWritableTextFile.writelines(lines)<span><a class="mark" href="#files_pwritabletextfile_writelines_lines" id="files_pwritabletextfile_writelines_lines">#</a></span></h2>
|
||||
<div class="signature"><ul>
|
||||
<li><code>lines</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 字符串数组</li>
|
||||
</ul>
|
||||
</div><p>把很多行写入到文件中....</p>
|
||||
<h2>PWritableTextFile.flush()<span><a class="mark" href="#files_pwritabletextfile_flush" id="files_pwritabletextfile_flush">#</a></span></h2>
|
||||
<p>把缓冲区内容输出到文件中。</p>
|
||||
<h2>PWritableTextFile.close()<span><a class="mark" href="#files_pwritabletextfile_close" id="files_pwritabletextfile_close">#</a></span></h2>
|
||||
<p>关闭文件。同时会被缓冲区内容输出到文件。</p>
|
||||
<p><strong>打开一个文件写入后,不再使用时务必关闭,否则文件可能会丢失</strong></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/sh_main.js"></script>
|
||||
<script src="assets/sh_javascript.min.js"></script>
|
||||
<script>highlight(undefined, undefined, 'pre');</script>
|
||||
<!-- __TRACKING__ -->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user