Java-I/O学习(4)

Java中的五种I/O模型详解 输入/输出(I/O)是计算机程序与外部环境(如文件、网络等)进行交互的方式。Java语言提供了多种I/O模型,帮助开发者处理数据读写和通信。本文将深入探讨Java中的五种I/O模型:阻塞I/O、非阻塞I/O、选择器I/O、NIO(New I/O)以及异步I/O,分析它们的工作原理、优缺点和适用场景,以帮助读者全面理解Java的I/O处理机制。 阅读详情

Java-I/O学习(4)

File

Java IO 的File类可以帮助你访问底层的文件系统,使用File类你可以:

  • 查看文件或目录是否存在

  • 如果目录不存在,可以创建

  • 读取文件的长度

  • 删除或移动文件

  • 删除文件

  • 查看路径指向的事文件还是目录

  • 读取目录下的文件列表

创建



// Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.
File​(String pathname)

// Creates a new File instance from a parent pathname string and a child pathname string.
File​(String parent,String child)

// Creates a new File instance from a parent abstract pathname and a child pathname string.
File​(File parent,String child)

// Creates a new File instance by converting the given file: URI into an abstract pathname.
File​(URI uri)

获取文件信息的方法


// Tests whether the application can execute the file denoted by this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to execute files that are not marked executable. Consequently this method may return true even though the file does not have execute permissions.
boolean canExecute()

//Tests whether the application can read the file denoted by this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to read files that are marked as unreadable. Consequently this method may return true even though the file does not have read permissions.
boolean canRead()

//Tests whether the application can modify the file denoted by this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to modify files that are marked read-only. Consequently this method may return true even though the file is marked read-only.
boolean canWrite()

//Tests whether the file or directory denoted by this abstract pathname exists.
boolean exists()


//Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\".
boolean isAbsolute()

//Tests whether the file denoted by this abstract pathname is a directory.Where it is required to distinguish an I/O exception from the case that the file is not a directory, or where several attributes of the same file are required at the same time, then the Files.readAttributes method may be used.
boolean  isDirectory()

//Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.Where it is required to distinguish an I/O exception from the case that the file is not a normal file, or where several attributes of the same file are required at the same time, then the Files.readAttributes method may be used.
boolean isFile()


//Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.
boolean isHidden()

//Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath()).
File getAbsoluteFile()


//Returns the canonical pathname string of this abstract pathname.
String getCanonicalPath()

//Returns the canonical form of this abstract pathname. Equivalent to new File(this.getCanonicalPath()).
File getCanonicalFile()

//Returns the absolute pathname string of this abstract pathname.
String getAbsolutePath()


//Returns the number of unallocated bytes in the partition named by this abstract path name.
long getFreeSpace()

///Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname. When possible, this method checks for write permissions and other operating system restrictions and will therefore usually provide a more accurate estimate of how much new data can actually be written than getFreeSpace().
long getUsableSpace()

//Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.
String getName()

//Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
String getParent()

//Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
File getParentFile()

//Converts this abstract pathname into a pathname string. The resulting string uses the default name-separator character to separate the names in the name sequence.
String getPath()

// Returns the size of the partition named by this abstract pathname.
long getTotalSpace()

使用:


    public static void main(String[] args) throws IOException {

        String pathName = "E:\\learn-java\\Learning-Java\\MyNotes\\better_write\\Java_IO\\d.txt";

        File file = new File(pathName);

        System.out.println("exists ? \n");
        System.out.println(file.exists());

        System.out.println("----------------------------------------------------------");

//        System.out.println(file.length());

        System.out.println("canExecute ? \n");
        System.out.println(file.canExecute());

        System.out.println("----------------------------------------------------------");

        System.out.println("canRead ? \n");
        System.out.println(file.canRead());

        System.out.println("----------------------------------------------------------");

        System.out.println("canWrite ? \n");
        System.out.println(file.canWrite());

        System.out.println("----------------------------------------------------------");

        System.out.println("isFile ? \n");
        System.out.println(file.isFile());

        System.out.println("----------------------------------------------------------");

        System.out.println("isDirectory ? \n");
        System.out.println(file.isDirectory());

        System.out.println("----------------------------------------------------------");

        System.out.println("isAbsolute ? \n");
        System.out.println(file.isAbsolute());

        System.out.println("----------------------------------------------------------");

        System.out.println("isHidden ? \n");
        System.out.println(file.isHidden());

        System.out.println("----------------------------------------------------------");

        System.out.println("getName  \n");
        System.out.println(file.getName());

        System.out.println("----------------------------------------------------------");

        System.out.println("getUsableSpace  \n");
        System.out.println(file.getUsableSpace());

        System.out.println("----------------------------------------------------------");

        System.out.println("getTotalSpace  \n");
        System.out.println(file.getTotalSpace());

        System.out.println("----------------------------------------------------------");

        System.out.println("getPath  \n");
        System.out.println(file.getPath());

        System.out.println("----------------------------------------------------------");


        System.out.println("getParentFile  \n");
        System.out.println(file.getParentFile());

        System.out.println("----------------------------------------------------------");


        System.out.println("getParent  \n");
        System.out.println(file.getParent());

        System.out.println("----------------------------------------------------------");

        System.out.println("getFreeSpace  \n");
        System.out.println(file.getFreeSpace());

        System.out.println("----------------------------------------------------------");

        System.out.println("getCanonicalPath  \n");
        System.out.println(file.getCanonicalPath());

        System.out.println("----------------------------------------------------------");


        System.out.println("getCanonicalFile  \n");
        System.out.println(file.getCanonicalFile());

        System.out.println("----------------------------------------------------------");
        
    }

创建新文件




// Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.
// Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.
boolean createNewFile()


//reates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. Invoking this method is equivalent to invoking createTempFile(prefix, suffix, null).The Files.createTempFile method provides an alternative method to create an empty file in the temporary-file directory. Files created by that method may have more restrictive access permissions to files created by this method and so may be more suited to security-sensitive applications.

//prefix - The prefix string to be used in generating the file's name; must be at least three characters long

//suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
static File createTempFile​(String prefix,String suffix)

//Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. If this method returns successfully then it is guaranteed that:

//1  The file denoted by the returned abstract pathname did not exist before this method was invoked, and
//2  Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.

//prefix - The prefix string to be used in generating the file's name; must be at least three characters long

//suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used

//directory - The directory in which the file is to be created, or null if the default temporary-file directory is to be used
static File createTempFile​(String prefix,String suffix,File directory)



  public static void main(String[] args) throws IOException {

        String pathName = "E:\\learn-java\\Learning-Java\\MyNotes\\better_write\\Java_IO\\op.txt";

        File file = new File(pathName);

        System.out.println("创建新文件\n");
        System.out.println(file.createNewFile());

        System.out.println("--------------");

        String prefix = "etcedk";

        String suffix = ".txt";


        File file2 = File.createTempFile(prefix,suffix);

        System.out.println(file2.getName());

        System.out.println(file2.getAbsolutePath());


    }

针对读写权限

//A convenience method to set the owner's execute permission for this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to execute files that are not marked executable.

//executable - If true, sets the access permission to allow execute operations; if false to disallow execute operations
boolean setExecutable​(boolean executable)

//Sets the owner's or everybody's execute permission for this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to execute files that are not marked executable.
//The Files class defines methods that operate on file attributes including file permissions. This may be used when finer manipulation of file permissions is required.

//executable - If true, sets the access permission to allow execute operations; if false to disallow execute operations

//ownerOnly - If true, the execute permission applies only to the owner's execute permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's execute permission from that of others, then the permission will apply to everybody, regardless of this value.
boolean setExecutable​(boolean executable,boolean ownerOnly)

//Sets the last-modified time of the file or directory named by this abstract pathname.
//All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified() method will return the (possibly truncated) time argument that was passed to this method.

//time - The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
boolean setLastModified​(long time)

//Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory will not change until it is either deleted or marked to allow write access. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to modify files that are marked read-only. Whether or not a read-only file or directory may be deleted depends upon the underlying system.
boolean setReadOnly()

//Sets the owner's or everybody's write permission for this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to modify files that disallow write operations.The Files class defines methods that operate on file attributes including file permissions. This may be used when finer manipulation of file permissions is required.

//writable - If true, sets the access permission to allow write operations; if false to disallow write operations

//ownerOnly - If true, the write permission applies only to the owner's write permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's write permission from that of others, then the permission will apply to everybody, regardless of this value.
boolean setWritable​(boolean writable,boolean ownerOnly)

//A convenience method to set the owner's write permission for this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to modify files that disallow write operations.
boolean setWritable​(boolean writable)

//Sets the owner's or everybody's read permission for this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to read files that are marked as unreadable.

//readable - If true, sets the access permission to allow read operations; if false to disallow read operations

//ownerOnly - If true, the read permission applies only to the owner's read permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's read permission from that of others, then the permission will apply to everybody, regardless of this value.
boolean setReadable​(boolean readable,boolean ownerOnly)

list


//Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

//If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

//There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

//Note that the Files class defines the newDirectoryStream method to open a directory and iterate over the names of the files in the directory. This may use less resources when working with very large directories, and may be more responsive when working with remote directories.
String[] list()



//Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
//If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.

//There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

//Note that the Files class defines the newDirectoryStream method to open a directory and iterate over the names of the files in the directory. This may use less resources when working with very large directories.
File[] listFiles()

使用


  public static void main(String[] args) {

        String pathName = "E:\\learn-java\\Learning-Java\\MyNotes\\better_write\\Java_IO";

        File file = new File(pathName);
        for (String s : file.list()) {

            System.out.println(s);

        }

        System.out.println("-------------------------------------------------");

        
        for (File f : file.listFiles()) {

            System.out.println(f.getAbsolutePath());
        }


    }

针对目录


//Creates the directory named by this abstract pathname.

//true if and only if the directory was created; false otherwise
boolean mkdir()

//Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

//true if and only if the directory was created, along with all necessary parent directories; false otherwise
boolean mkdirs()

使用:



 public static void main(String[] args) {

        String pathName = "E:\\learn-java\\Learning-Java\\MyNotes\\better_write\\Java_IO\\IG";

        File file = new File(pathName);

        System.out.println("创建目录 : \n");

        System.out.println(file.mkdir());


    }
【Java】I/O 流篇 —— 字节 I/O 流 I/O流(Input/Output Stream)是计算机中数据传输的一种抽象概念,用于描述数据在程序和外部设备(如文件、网络、内存等)之间的流动方式。可以将它想象成一条“数据管道”,数据像水流一样在这条管道中连续传输。作用:I/O 流用于读写文件中的数据(可以是读写文件,或网络中的数据)。读(Read) → Input(输入)当程序从外部(如文件、键盘、网络等)获取数据时,称为“读”操作。例如:读取文件内容、接收用户键盘输入、获取网络数据等。这属于输入(Input) 阅读详情

相关推荐

【SABRE 3D, SABRE 3DxT,LAM设备】2025年9月12日-生产期间维护用的双重隔离

生产期间维护用的双重隔离。该程序用于准备将一个或多个双工位设置为维护状态,同时SABRE 3D/3DxT/3D Scimitar保持生产运行。其目的是在不中断生产的情况下将双工位与运行中的设备隔离。

weixin_46735260的博客 573

java.io.file 中mkdir和mkdirs的区别

mkdir public boolean mkdir() Creates the directory named by this abstract pathname. Returns:true if and only if the directory was created; false otherwise Throws:SecurityException - If a secur

Joker_honey的博客 1256

深入解析PVT corner:从wcl到ml的芯片设计关键考量

本文深入解析了芯片设计中的PVT corner概念,重点探讨了从传统WC到先进工艺下WCL、ML等关键工艺角。文章详细阐述了温度反转效应如何使低温WCL成为最严苛的时序场景,并提供了基于先进工艺的实战签核策略与多角多模分析流程,确保芯片在极端工艺、电压、温度下的稳健性。

tree8的博客 524

android mkdir失败_从mkdir()创建文件失败

I try to create file in my android emulator, but when i finish my code.I can't find the file i create from android device monitor.Here is my code:try {if (Environment.getExternalStorageState().equals(...

weixin_39614228的博客 1840

开源分享:苹果群控手机源代码解析与实战

本文介绍了苹果设备群控的基本原理和实现方法,重点解析了基于Python+Appium的群控系统构建。主要内容包括:1)设备连接管理技术(USB/Wi-Fi);2)自动化控制方式(WDA/AppleScript/Appium);3)实战演示了通过Python脚本实现多设备同时控制,涵盖环境配置、代码解析和功能说明;4)提出了多线程、图像识别等优化方向。文章为开发者提供了快速上手的群控方案,适用于自动化测试、批量管理等场景,并推荐了相关开源项目参考。

2403_88540309的博客 1343

【C++】小猫钓鱼纸牌游戏--C++实现

小猫钓鱼问题: 描述:初始,两个人各有n张牌(牌面0-10),顺序固定,只能按顺序出牌。然后,两个人轮流在桌面上以接龙的方式出牌,当某个人放置的牌在桌面上已经出现时,他收起相同牌面及其中间的牌作为自己的筹码,同时需要再放一张牌到桌面。某人手上的牌出完后,另一个人继续出,直到两人手上都没牌为止,输出结束时两个人手上的筹码数。 #include<iostream> using namespace std; struct queue { int head; //队列首 int tail; //

qq_41344430的博客 3202

Java文件类– java.io.File

Java File class is at the center of Java IO operations. Java File类是Java IO操作的中心。 Java文件类 (Java File Class) Java File class is a part of java.io package. Java File类是java.io包的一部分。 Java File class is a...

从零开始的教程世界 934

从Podfile到分享成功:ShareSDK小红书模块集成全流程实战(附视频分享代码)

本文详细介绍了iOS应用如何通过ShareSDK集成小红书分享功能的全流程,包括环境配置、SDK初始化、图片和视频分享实现,以及常见问题排查和性能优化策略。特别针对视频分享这一高频需求场景,提供了完整的代码示例和实战技巧,帮助开发者快速实现社交分享功能。

weixin_42540248的博客 226

java进阶-第十二讲 IO流

java进阶-第十二讲 IO流 1 File类 在java中File类代表了什么意思? file:文件 java中File类的描述: An abstract representation of file and directory pathnames. File代表了文件和目录,不仅仅只是文件,一定要清楚 2 File的构造方法 File(File parent, String child) Creates a new File instance from a parent abstr

solo_jie的博客 493

【个人成长笔记】在Ubuntu中安装RTL8188GU USB无线网卡驱动(Driver for Linux RTL8188GU)

这篇笔记提供了在Ubuntu系统中安装RTL8188GU无线网卡驱动的完整指南。主要内容包括:驱动程序的官方来源(Github链接)、详细安装步骤(通过git下载、编译安装等命令),以及将设备转换为USB网卡模式的关键指令。特别提醒每次开机都需要执行模式转换命令,因为设备默认会以U盘模式启动。文章以简洁的技术文档形式呈现,适合Linux用户快速查阅和操作。

yuhuasheng1997的博客 1822

真题库系列之 CCF GESP 2025年12月认证 Python 1级真题含正确答案与解析

学生通过计算机基础知识的学习,了解计算机的构成与操作,以及计算机的发 展历程。通过编程基础知识以及语句的掌握,可以独立完成简单功能的顺序结构、 分支结构、循环结构的程序。

iCloudEnd的博客 315

深入理解JavaI/O流

其实我个人觉得,javaI/O流是一种比较乏味的事情。因为看不到明显的运行效果,但是输入输出程序都需要用到I/O操作即:允许程序读取外部数据、用户输入数据,使用输出机制允许程序记录运行状态,将数据仅处理。Java中的I/O通过java.io中的类和接口支持,java中的IO流包括字符流和字节流,两大类除此之外java的IO中还是用了一种模式:装饰模式          将IO流分成底层的节点流和

Blue的博客 3390

Transformer在BEV感知中的统治地位

Transformer在BEV感知中的统治地位 ,人工智能,计算机视觉,大模型,AI,本文围绕 Transformer 在 BEV 感知中的统治地位展开,介绍了 Transformer 的基础原理,如自注意力、多头注意力机制等,以及 BEV 感知的概念、任务与挑战。阐述了 Transformer 在 BEV 感知中的技术优势,包括全局建模、灵活特征融合和长距离依赖捕捉能力,还介绍了典型架构、代码示例及在自动驾驶目标检测等领域的应用案例。同时,评估了其性能,提及优化方法,并展望了与其他技术融合、端到端系统等…

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 20万+

Netty4核心原理学习之JAVA I/O演讲之路

1、什么是I/O 我所理解的I/O操作,简而言之就是流,包括往流中读出数据,系统调用read,写入数据,系统调用write。操作系统都是通过内核创建文件描述符FD(File Descriptor,FD)来标识的,一个FD就是一个非负整数,所以对这个额整数的操作就是对这个文件(流)的操作。 2、/O交互流程 I/O交互流程分为两阶段:首先是经过内核空间,也就是有操作系统处理;紧接着就是到用户空间,也就是交由应用程序。 内核空间存放的是内核代码和数据,而进程的用户空间存放的是用户程序的代码和数据,不管是内核空

HeyDogBro的博客 322

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

java学习笔记4——I/O流

1、I/O流  也叫做输入输出流  是Java的网络编程的基础

shawshank_bingo的博客 380

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Java 当中的I/O(一) -- MarsChen Java4Android 教程学习笔记

I/O 操作的基本目标 从数据源当中读取数据,以及将数据写入到数据目的地当中。数据源不是硬盘上的文件,数据的目的地也不是硬盘。而是:【文件、键盘、网络→Java 程序→ 文件、屏幕、网络】。 要搞清楚数据的流向 ,从文件到程序是输入流,从程序到文件是输出流,搞清楚出入关系才能写对程序。I/O 的分类方法 1、输入流和输出流; 2、字节流和字符流(每一次传输字符/字节); 3、节点流和处理流(有关J

渣渣随手记 573

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

java 字符流异常处理_Java编程学习摘要(4)异常处理和I/O流

Java编程学习摘要(4)异常处理和I/O流重点:  1.在编写程序时,要正确地使用捕获例外和声明抛出异常的两种例外处理的方法。2.遇到实际问题时,要根据需要正确使用各种输入/输出流,特别是对中文使用适当的字符输入流。3.正确使用对象串行化的方法。难点:1.如何使用Java中两种异常处理机制,抛弃异常和声明抛弃异常的区别与联系。2.处理字符流时,其构造方法的参数是一个字节流。3.对象串行化的概念。...

weixin_35935249的博客 327

Java I/O模型的演变:从阻塞I/O到异步I/O的底层机制解析

以上代码示例展示了各种I/O模型的基本用法,从阻塞I/O的简单粗暴,到异步I/O的高效并发,每种模型都有其适用的场景。理解这些模型的底层机制,可以帮助我们根据实际需求选择合适的I/O模型,编写出高性能、高并发的Java应用程序。I/O模型的演进是为了解决并发问题,选择哪种模型取决于具体场景。阻塞I/O简单但并发低,非阻塞I/O解决了阻塞但消耗CPU,I/O多路复用提高并发,异步I/O实现了真正的高效并发。

weixin_41455464的博客 1495

什么是I/O?

计算机有输入设备(键盘等)和输出设备(显示屏等),(网卡和硬盘既可以作为输入也可以作为输出)。所以从计算机结构角度来看,I/O描述的是。为了保证操作系统的安全性和稳定性,一个进程的地址空间被分为和。我们平时的应用程序都是运行在用户空间,而像等都是需要依赖内核空间来完成的。而我们要执行I/O操作时,由于我们没有权限,所以只有,让操作系统来帮我们完成。而我们一般开发常见的就是。所以从应用程序来看,I/O是指我们的应用程序,将我们需要的数据从内核空间拷贝到用户空间。

m0_51808048的博客 6725

Java的I/O历史

Java的I/O历史

AiFlutter的博客 1251

Java的I/O演进之路

一、I/O 基础入门 Java1.4之前的早期版本,对I/O的支持并不完善,开发人员在开发java高性能IO程序的时候,会面临一些巨大的挑战和困难,主要问题如下: 没有数据缓存区,IO性能存在问题 没有C或者C++的Channel概念,只有输入、输出流 同步阻塞式I/O通信(BIO),通常会让通讯线程长时间的阻塞服务端的响应 支持的字符集有限,硬件可移植性不好 在Java支持异步通讯之前的很长一段时间里,一直都是C/C++长期占据着高性能服务端程序开发的语言,Java的同步阻塞式I/O一直被人们锁所诟病

csdn5215的博客 8016

Java NIO编程理论基础篇——Java I/O的发展以及linux网络I/O模型

发展简述: Java在jdk1.4之前,Java对I/O的支持并不完善,开发人员会遇到许多问题,例如: 没有数据缓冲区,性能较低; 没有C或者C++中的Channel概念,通常 ...

sdr_zd的博客 5677

Java技术——I/O知识学习

0. 前言 I/O是Java技术网络中一个比较重要的点,不仅是平时开发中的家常便饭,也是面试的时候经常被问到的话题。本篇将介绍字节IO、字符IO的基本体系和用法,最后总结一下NIO的一些知识。1. 字节I/O字节流处理单元为1个字节,主要用在处理二进制数据,字节用来与文件打交道,所有文件的储存都是通过字节(byte)的方式,在磁盘上保留的并不是文件的字符而是先把字符编码成字节,再储存这些字节...

关于Android开发的一些技术点总结 ╮( ̄▽ ̄”)╭ 1万+

java学习——I/O

/根据提供的文件信息构建一条文件输出通道,并根据append的值决定是将内容追加到末尾还是直接覆盖public Fileoutputstream(File file, boolean append) throws FileNotFoundException;磁盘和内存是两个不同的设备,它们之间要实现数据的交互,就必须要建立一条通道, 在Java中实现建立这样的通道的是I/0流。到目前为止,我们看到的大多数示例都使用无缓冲的I/O。正如二进制数据流支持原始数据类型的I/O一样,对象流也支持对象的I/O。

ping12138的博客 930

Java的I/O模型

不同的I/O模型由于线程模型、API等差别很大,所以用法的差异也非常大。

fengshi95的博客 908

Java—I/O操作

IO 即,输入和输出。数据输入到计算机内存的过程即输入,反之输出到外部存储(比如数据库,文件,远程主机)的过程即输出。数据传输过程类似于水流,因此称为 IO 流。IO 流在 Java 中分为输入流和输出流,而根据数据的处理方式又分为字节流和字符流。Java I0 流的 40 多个类都是从如下 4 个抽象类基类中派生出来的。InputStream/Reader: 是所有的输入流的基类,InputStream是字节输入流,Reader是字符输入流。

m0_54049074的博客 1034
上一篇: Java-I/O学习(3)
下一篇: Java-I/O学习(5)
Coder_py
博客等级 码龄10年 106粉丝 258原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值