015-PHP读取TXT记事本内容

<?php
    print("<H3>通过http协议打开文件</H3>\n");
    // 通过 http 协议打开文件
    if (!($myFile = fopen("data.txt", "r"))) {
        print("文件不能打开");
        exit;
    } else {
        // 读取文件中的内容
        echo fread($myFile, filesize("data.txt"));
    }
    // 关闭文件的句柄
    fclose($myFile);
?>

data.txt如下:

原文地址:https://www.cnblogs.com/tianpan2019/p/10982352.html

时间: 2024-08-29 14:02:44

015-PHP读取TXT记事本内容的相关文章

017-PHP数组形式读取TXT记事本内容

<?php // 打开文件同时,输出每一行 $myFile = file("data.txt"); for ($index = 0; $index < count($myFile); $index++) { print($myFile[$index] . "<BR>"); } ?> 原文地址:https://www.cnblogs.com/tianpan2019/p/10982410.html

C#生成PDF文档,读取TXT文件内容

using System.IO;using iTextSharp.text;using iTextSharp.text.pdf; //需要在项目里引用ICSharpCode.SharpZipLib.dll和itextsharp.dllpublic string TxtFilePath;public string SavePdfPath;//保存PDF的路径 #region 读取TXT内容        private string ReadXieyi(string FilePath)      

C# winfrom 读取txt文本内容

第一种: /// <summary> /// 读取txt文件内容 /// </summary> /// <param name="Path">文件地址</param> public void ReadTxtContent(string Path) { StreamReader sr = new StreamReader(Path, Encoding.Default); string content; while ((content = s

C++ 读取txt文本内容,并将结果保存到新文本

循序渐进学习读文件 1 // readFile.cpp : 定义控制台应用程序的入口点. 2 3 4 #include "stdafx.h" 5 #include <iostream> 6 #include <fstream> 7 #include <string> 8 using namespace std; 9 10 //引申:文件拷贝 11 void fileCopy(string file1,string file2){ 12 ifstrea

android 读取txt文件内容

Android的res文件夹是用来存储资源的,可以在res文件夹下建立一个raw文件夹,放置在raw文件夹下的内容会被原样打包,而不会被编译成二进制文件,并且可以通过R文件进行很方便地访问. 比如我们可以将更新信息.版权信息等放到txt文件中,然后放到raw文件中,然后很方便地进行访问. 在raw中放入一个a.txt文件,然后就可以在Activity中使用getResources().openRawResource(R.raw.a);方法获取一个此文件的InputStream类,而后就可以很方便

python web开发-flask中读取txt文件内容

某些情况下,需要读取flask网站要目录下的txt文件.但是直接在flask网站的目录下创建一个文件是无法访问的.从网站找了一些资料,最终发现通过写一个方法返回txt内容比较简单方便,不过此方法适用于简单的文件读取以及读取量比较小的时候.详细代码如下: @app.route('/<path>')def today(path):base_dir = os.path.dirname(__file__)resp = make_response(open(os.path.join(base_dir,

C#获取txt记事本内容,防止乱码情况

StreamReader sr = new StreamReader(@"E:\人名.txt", Encoding.GetEncoding("GB2312")); string readText = sr.ReadToEnd();

Java(springboot) 读取txt文本内容

public class TxtTest { private static final Logger logger = LoggerFactory.getLogger(TxtTest.class); public static String readTxt(File file) throws IOException { String s = ""; InputStreamReader in = new InputStreamReader(new FileInputStream(file

java读取txt文件内容

File file = new File(this.getClass().getResource("").getPath());System.out.println(file.getPath());String path=file.getPath();//path=path.substring(0,path.indexOf("WEB-INF"))+"upload\\Excel"+"\\"+"import.txt&qu