JAVA August 20, 2018

java_IO编程

Words count 4.4k Reading time 4 mins.

什么是流?

流是一个抽象出来的概念,具体说是对[输入/输出]设备的抽象(内存、网络、磁盘),对系统读写API的封装,对外提供数据操作接口

基本概念

流:数据在文件和程序(内存)之间经历的路径
输入流:数据从...

Read article

JAVA August 19, 2018

练习1:文件操作和目录遍历

Words count 2.7k Reading time 2 mins.

String getName() //得到一个文件的名称(不包括路径)

String getPath() //得到一个文件的路径名

String getAbsolutePath() //得到一个文件的绝对路径名

String getParent() //得到一个文件的上一级路径名

String renameTo(File newname)
//将当前文件名更名为给定文件的完整路径

boolean exists() //判断指定的文件或目录是否存在

boolean mkdir() //创建文件对象...

Read article

JAVA August 19, 2018

练习4:字符流的写入FileWriter

Words count 892 Reading time 1 mins.

实例:

package com.inspur.io;

import java.io.FileWriter;

/**
 * Created by shirukai on 2017/7/26.
 *
 */
public class Filewrite {
    public static void main(String[] args){
        Filewrite filewrite = new Filewrite();
        filewrite.fileWrite();
    }
    public void...
Read article

JAVA August 19, 2018

练习5:字符流的读取 FileReader

Words count 1.1k Reading time 1 mins.

实例:

package com.inspur.io;

import java.io.File;
import java.io.FileReader;

/**
 * Created by shirukai on 2017/7/26.
 *
 */
public class Filereader {
    public static void main(String[] agrs){
        Filereader filereader = new Filereader();
        filereader.fileReader...
Read article

JAVA August 19, 2018

练习2:字节流读取FileInputStream

Words count 1.1k Reading time 1 mins.

package com.inspur.io;
import java.io.File;
import java.io.FileInputStream;

/**
 * Created by shirukai on 2017/7/26.
 *
 */
public class Fileinputstream {
    public static void main(String[] args){
        Fileinputstream fileinputstream = new Fileinputstream...
Read article

JAVA August 19, 2018

练习3:字节流写入FileOutputStream

Words count 944 Reading time 1 mins.

package com.inspur.io;

import java.io.File;
import java.io.FileOutputStream;

/**
 * Created by shirukai on 2017/7/26.
 *
 */
public class Fileoutstream {
    public static void main(String[] args){
        Fileoutstream fileoutstream = new Fileoutstream()...
Read article
0%