/* StreamTypeEnum Values
*/
var adTypeBinary = 1;
var adTypeText = 2;
/* LineSeparatorEnum Values
*/
var adLF = 10;
var adCR = 13;
var adCRLF = -1;
/* StreamWriteEnum Values
*/
var adWriteChar = 0;
var adWriteLine = 1;
/* SaveOptionsEnum Values
*/
var adSaveCreateNotExist = 1;
var adSaveCreateOverWrite = 2;
/* StreamReadEnum Values
*/
var adReadAll = -1;
var adReadLine = -2;
/* charset の値の例:
* _autodetect, euc-jp, iso-2022-jp, shift_jis, unicode, utf-8,…
*/
/* filename: 読み込むファイルのパス
* charset: 文字コード
* 戻り値: 文字列
*/
function adoLoadText(filename, charset) {
var stream, text;
stream = new ActiveXObject(“ADODB.Stream”);
stream.type = adTypeText;
stream.charset = charset;
stream.open();
stream.loadFromFile(filename);
text = stream.readText(adReadAll);
stream.close();
return text;
}
/* filename: 読み込むファイルのパス
* charset: 文字コード
* 戻り値: 行単位の文字列の配列
*/
function adoLoadLinesOfText(filename, charset) {
var stream;
var lines = new Array();
stream = new ActiveXObject(“ADODB.Stream”);
stream.type = adTypeText;
stream.charset = charset;
stream.open();
stream.loadFromFile(filename);
while (!stream.EOS) {
lines.push(stream.readText(adReadLine));
}
stream.close();
return lines;
}
/* filename: 書き出すファイルのパス
* charset: 文字コード
*/
function adoSaveText(filename, text, charset) {
var stream;
stream = new ActiveXObject(“ADODB.Stream”);
stream.type = adTypeText;
stream.charset = charset;
stream.open();
stream.writeText(text);
stream.saveToFile(filename, adSaveCreateOverWrite);
stream.close();
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/182039.html原文链接:https://javaforall.cn