最全【(4),0基础学大数据开发

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取


##### ♉ 构造函数


###### PipeStream(PipeDirection, Int32) 使用指定的 PipeDirection 值和缓冲区大小初始化 PipeStream 类的一个新实例



protected PipeStream (System.IO.Pipes.PipeDirection direction, int bufferSize);


**参数**



> 
> `direction`
> 
> 
> [PipeDirection](https://bbs.csdn.net/topics/618545628)
> 
> 
> [PipeDirection](https://bbs.csdn.net/topics/618545628) 值之一,指示管道对象的方向。
> 
> 
> `bufferSize`
> 
> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> 一个大于或等于 0 的正 [Int32](https://bbs.csdn.net/topics/618545628) 值,指示缓冲区大小。
> 
> 
> 



> 
> **PipeDirection 枚举**
> 
> 
> 
> 
> | In | 1 | 指定管道方向为向内。 |
> | --- | --- | --- |
> | InOut | 3 | 指定管道方向为双向。 |
> | Out | 2 | 指定管道方向为向外。 |
> 
> 
> 


##### ♊ 属性


###### CanRead 获取一个值,该值指示当前流是否支持读取



public override bool CanRead { get; }


###### CanWrite 获取一个值,该值指示当前流是否支持写入



public override bool CanWrite { get; }


###### InBufferSize 获取管道的入站缓冲区的大小(以字节为单位)



public virtual int InBufferSize { get; }


###### IsAsync 获取一个值,该值指示 PipeStream 对象是异步打开还是同步打开



public bool IsAsync { get; }


###### IsConnected 获取或设置一个值,该值指示是否已连接 PipeStream 对象



public bool IsConnected { get; protected set; }


###### Length 获取流长度(以字节为单位)



public override long Length { get; }


###### OutBufferSize 获取管道的出站缓冲区的大小(以字节为单位)



public virtual int OutBufferSize { get; }


##### ♌ 常用方法


###### Close() 关闭当前流并释放与之关联的所有资源(如套接字和文件句柄)



public virtual void Close ();



> 
> 注意:此方法调用 [Dispose](https://bbs.csdn.net/topics/618545628) ,指定 `true` 以释放所有资源。 不需要专门调用 [Close](https://bbs.csdn.net/topics/618545628) 方法。 请确保 [Stream](https://bbs.csdn.net/topics/618545628) 已正确释放每个对象。 可以 [Stream](https://bbs.csdn.net/topics/618545628) `using` `Using` 在 Visual Basic) 中 (或块中声明对象,以确保释放流及其所有资源,或者可以显式调用 [Dispose](https://bbs.csdn.net/topics/618545628) 方法。
> 
> 
> 


###### CopyTo(Stream) 从当前流中读取字节并将其写入到另一流中



public void CopyTo (System.IO.Stream destination);


**参数**



> 
> `destination`
> 
> 
> **Stream**
> 
> 
> 当前流的内容将复制到的流。
> 
> 
> 


**示例**


下面的示例将的内容复制 [FileStream](https://bbs.csdn.net/topics/618545628) 到 [MemoryStream](https://bbs.csdn.net/topics/618545628) 中。



// Create the streams.
MemoryStream destination = new MemoryStream();

using (FileStream source = File.Open(@“c:\temp\data.dat”,
FileMode.Open))
{

Console.WriteLine("Source length: {0}", source.Length.ToString());

// Copy source to destination.
source.CopyTo(destination);

}

Console.WriteLine(“Destination length: {0}”, destination.Length.ToString());


###### CopyTo(Stream, Int32) 使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中



public virtual void CopyTo (System.IO.Stream destination, int bufferSize);


**参数**



> 
> `destination`
> 
> 
> **Stream**
> 
> 
> 当前流的内容将复制到的流。
> 
> 
> `bufferSize`
> 
> 
> **Int**
> 
> 
> 缓冲区的大小。 此值必须大于零。 默认大小为 81920。
> 
> 
> 


###### CopyToAsync(Stream) 从当前流中异步读取字节并将其写入到另一个流中



public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream destination);


**参数**



> 
> `destination`
> 
> 
> **Stream**
> 
> 
> 当前流的内容将复制到的流。
> 
> 
> 


**示例**


下面的示例演示如何使用两个 [FileStream](https://bbs.csdn.net/topics/618545628) 对象将文件从一个目录异步复制到另一个目录。 [FileStream](https://bbs.csdn.net/topics/618545628) 类是从 [Stream](https://bbs.csdn.net/topics/618545628) 类派生的。 请注意, [Click](https://bbs.csdn.net/topics/618545628) 控件的事件处理程序 [Button](https://bbs.csdn.net/topics/618545628) 使用修饰符标记, `async` 因为它调用异步方法



using System;
using System.Threading.Tasks;
using System.Windows;
using System.IO;

namespace WpfApplication
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        string StartDirectory = @"c:\Users\exampleuser\start";
        string EndDirectory = @"c:\Users\exampleuser\end";

        foreach (string filename in Directory.EnumerateFiles(StartDirectory))
        {
            using (FileStream SourceStream = File.Open(filename, FileMode.Open))
            {
                using (FileStream DestinationStream = File.Create(EndDirectory + filename.Substring(filename.LastIndexOf('\\'))))
                {
                    await SourceStream.CopyToAsync(DestinationStream);
                }
            }
        }
    }
}

}



> 
> [CopyToAsync](https://bbs.csdn.net/topics/618545628)方法使你可以在不阻塞主线程的情况下执行占用大量资源的 i/o 操作。
> 
> 
> 


###### Dispose() 释放由 Stream 使用的所有资源



public void Dispose ();


###### Read(Byte[], Int32, Int32) 从指定长度的指定位置开始,从流中读取一个字节块,并将数据写入指定的缓冲区



public override int Read (byte[] buffer, int offset, int count);


**参数**



> 
> `buffer`
> 
> 
> [Byte](https://bbs.csdn.net/topics/618545628)[]
> 
> 
> 当此方法返回时,包含指定的字节数组,此数组中 `offset` 和 (`offset` + `count` - 1) 之间的值被从当前源中读取的字节所替换。
> 
> 
> `offset`
> 
> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> `buffer` 数组中的字节偏移量,其中读取的字节将被替换。
> 
> 
> `count`
> 
> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> 最多读取的字节数。
> 
> 
> 


**返回**



> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> 读取到 `buffer` 的总字节数。 如果当前可用的字节数没有请求的那么多,则此数小于请求的字节数;或如果已到达流的末尾,则为零。
> 
> 
> 


**示例**


以下示例创建匿名管道客户端和管道服务器。 管道服务器使用 [Read](https://bbs.csdn.net/topics/618545628) 此方法从管道客户端读取一系列字节作为验证代码。 管道客户端和管道服务器都是同一示例的一部分。 该示例的服务器部分将创建一个客户端进程,并将其作为参数传递给匿名管道句柄。



using System;
using System.IO;
using System.IO.Pipes;
using System.Diagnostics;

class PipeStreamExample
{
private static byte[] matchSign = {9, 0, 9, 0};

public static void Main()
{
    string[] args = Environment.GetCommandLineArgs();
    if (args.Length < 2)
    {
        Process clientProcess = new Process();

        clientProcess.StartInfo.FileName = Environment.CommandLine;

        using (AnonymousPipeServerStream pipeServer =
            new AnonymousPipeServerStream(PipeDirection.In,
            HandleInheritability.Inheritable))
        {
            // Pass the client process a handle to the server.
            clientProcess.StartInfo.Arguments = pipeServer.GetClientHandleAsString();
            clientProcess.StartInfo.UseShellExecute = false;
            Console.WriteLine("[SERVER] Starting client process...");
            clientProcess.Start();

            pipeServer.DisposeLocalCopyOfClientHandle();

            try
            {
                if (WaitForClientSign(pipeServer))
                {
                    Console.WriteLine("[SERVER] Valid sign code received!");
                }
                else
                {
                    Console.WriteLine("[SERVER] Invalid sign code received!");
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("[SERVER] Error: {0}", e.Message);
            }
        }
        clientProcess.WaitForExit();
        clientProcess.Close();
        Console.WriteLine("[SERVER] Client quit. Server terminating.");
    }
    else
    {
        using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.Out, args[1]))
        {
            try
            {
                Console.WriteLine("[CLIENT] Sending sign code...");
                SendClientSign(pipeClient);
            }
            catch (IOException e)
            {
                 Console.WriteLine("[CLIENT] Error: {0}", e.Message);
            }
        }
        Console.WriteLine("[CLIENT] Terminating.");
    }
}

private static bool WaitForClientSign(PipeStream inStream)
{
    byte[] inSign = new byte[matchSign.Length];
    int len = inStream.Read(inSign, 0, matchSign.Length);
    bool valid = len == matchSign.Length;

    while (valid && len-- > 0)
    {
        valid = valid && (matchSign[len] == inSign[len]);
    }
    return valid;
}

private static void SendClientSign(PipeStream outStream)
{
    outStream.Write(matchSign, 0, matchSign.Length);
}

}



> 
> [CanRead](https://bbs.csdn.net/topics/618545628)使用属性确定当前[PipeStream](https://bbs.csdn.net/topics/618545628)对象是否支持读取操作。
> 
> 
> [Read](https://bbs.csdn.net/topics/618545628)调用方法块,直到`count`读取字节或到达流的末尾。 有关异步读取操作,请参阅 [BeginRead](https://bbs.csdn.net/topics/618545628) 和 [EndRead](https://bbs.csdn.net/topics/618545628)。
> 
> 
> 


###### ReadAsync(Byte[], Int32, Int32) 从当前流异步读取字节序列,并将流中的位置提升读取的字节数



public System.Threading.Tasks.Task ReadAsync (byte[] buffer, int offset, int count);


**参数**



> 
> `buffer`
> 
> 
> [Byte](https://bbs.csdn.net/topics/618545628)[]
> 
> 
> 要写入数据的缓冲区。
> 
> 
> `offset`
> 
> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> `buffer` 中的字节偏移量,从该偏移量开始写入从流中读取的数据。
> 
> 
> `count`
> 
> 
> [Int32](https://bbs.csdn.net/topics/618545628)
> 
> 
> 最多读取的字节数。
> 
> 
> 


**返回**



> 
> [Task](https://bbs.csdn.net/topics/618545628)<[Int32](https://bbs.csdn.net/topics/618545628)>
> 
> 
> 表示异步读取操作的任务。 `TResult` 参数的值包含读入缓冲区的总字节数。 如果当前可用字节数少于所请求的字节数,则该结果值可小于所请求的字节数;如果已到达流结尾时,则为 0(零)。
> 
> 
> 


**示例**


下面的示例演示如何以异步方式从文件读取。 该示例使用 [FileStream](https://bbs.csdn.net/topics/618545628) 类,该类派生自 [Stream](https://bbs.csdn.net/topics/618545628) 类。



using System;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.IO;

namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        string filename = @"c:\Temp\userinputlog.txt";
        byte[] result;

        using (FileStream SourceStream = File.Open(filename, FileMode.Open))
        {
            result = new byte[SourceStream.Length];
            await SourceStream.ReadAsync(result, 0, (int)SourceStream.Length);
        }

        UserInput.Text = System.Text.Encoding.ASCII.GetString(result);
    }
}

}



![img](https://img-blog.csdnimg.cn/img_convert/55f764f18e0544a516c57d00f6e01387.png)
![img](https://img-blog.csdnimg.cn/img_convert/7725700f661d73471c6d5700200a2a76.png)
![img](https://img-blog.csdnimg.cn/img_convert/5044d711675d9e4e193e0e4ec1624a01.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**

               result = new byte[SourceStream.Length];
                await SourceStream.ReadAsync(result, 0, (int)SourceStream.Length);
            }

            UserInput.Text = System.Text.Encoding.ASCII.GetString(result);
        }
    }
}

[外链图片转存中…(img-9DNtIxjb-1715798299928)]
[外链图片转存中…(img-z59L6Q0C-1715798299929)]
[外链图片转存中…(img-hMaULOq4-1715798299929)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

  • 23
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值