zoukankan      html  css  js  c++  java
  • 读取文件txt

            /// <summary>
            /// 读取文件
            /// </summary>
            /// <param name="path"></param>
            /// <returns></returns>
            public static String ReadFile()
            {
                string path = AppDomain.CurrentDomain.BaseDirectory+"data.txt";
                Log(path);
                Log(File.Exists(path)?"存在":"不存在");
                if (File.Exists(path))
                {
       
                    byte[] byData = new byte[1000];
                    char[] charData = new char[10000];
                    try
                    {
                        StreamReader sr = new StreamReader(path, Encoding.Default);
                        String line;
                        var result = "";
                        while ((line = sr.ReadLine()) != null)
                        {
                            result+=line;
                        }
                        Log(result);
                        return result;
                    }
                    catch (IOException e)
                    {
                        Log(e.Message);
                        return "";
                    }
                }
                return "";
            }

  • 相关阅读:
    Django框架 之 logging配置
    Django框架 之 中间件
    Django框架 之 form组件
    Django框架 之 Ajax
    Django框架 之 Pagination分页实现
    3张图带你看懂扩展KMP(EXKMP)
    [TJOI2018]游园会(状压dp+LCS)
    [BZOJ 2959] 长跑(LCT+并查集)
    [NAIPC2016]Jewel Thief(决策单调性+分治)
    [BZOJ 1563] [NOI 2009] 诗人小G(决策单调性)
  • 原文地址:https://www.cnblogs.com/change4now/p/5665199.html
Copyright © 2011-2022 走看看