NewFile =NewFile (dest, sb1.tostring ()); //one more time. Loop through the files and folders in this number of times Group for(File file3:file) {//If you have the same file in it, delete it in the rename if(File3.isfile () newfile.getname (). Equals (File3.getname ())) {File3.delete (); }
Common APIs for Java-IO stream File, javaiofileapi
File class
1. It is only used to indicate the information (name, size, etc.) of the file (directory) and cannot be used to access the file content.
Package cn. test; import
pairs are all strings, no generics requiredis a collection container that combines IO technology in the collection. the characteristics of the object: can be used in the form of key-value pairs of configuration files, you can manipulate the hard disk key-value pairs. String GetProperty (String key)//Return value Object SetProperty (string key,string value)//Modify value/Set Value list (PrintStream out)// Assigns a list of attributes to the output str
[IE download file -- ClientAbortException: java. io. IOException error reported in the background ],
I. Scenarios
You can download an Excel file to download data in a report.
Test in chrome and IE respectively. It is normal in chrome, and an error is reported in IE background.
Ii. error message
Org. apache. catalina. c
Illustration of Java IO: 1. File source code, iofile
Writer: BYSocket)
Weibo: BYSocket
Bean flap: BYSocket
FaceBook: BYSocket
Twitter: BYSocket
I remember that the Java source code was first read by the set. I wrote a series of articles related to the set, which was well evaluated. Thank you. I will still read the old
and folders it contains by calling the list () method on the object.The example shown below shows how to use the list () method to check what is contained in a folder:Dirlist.java File Code:Import Java.io.File; public class Dirlist {public static void main (string args[]) { string dirname = "/tmp"; File F1 = new file (dirname); if (F1.isdirectory ()) {
(file);} }
}
}
Test class:
public class Fileutilstest {public
static void Main (string[] args) throws IOException {
fileutils.listdirectory (New File ("D:\\iostudy"));
}
Run Result:
Third, the use of Randomaccessfile class
Randomaccessfile:java provides access to the contents of a file, either by reading a
I. Overview of IO:Storing the in-memory data to the hard disk (persistent device) is called: output (write) outputsoperation. Java software goes to the computer hard drive called output.The data in the hard drive is read into memory called: input (read)operation. On your computer's hard drive, go to Java software and call input.Use Java Software as a reference.Th
Java compares IO and NIO file read/write performance tests, ionio
Original article: test the file read/write performance of IO and NIO in java
Source code: http://www.zuidaima.com/share/1550463508466688.htm
1. NIO adopts a me
here is the default character set.Writing is also similar to the process as shown in:Through the OutputStreamWriter class, the character-to-byte encoding process is completed by the Streamencoder encoding process.Example: using the transform stream inputstreamreader and OutputStreamWriterThe conversion flow is required when converting between a byte stream and a character stream, or when you want to encode bytes of data PackageOrg.example.io;ImportJava.io.File;ImportJava.io.FileInputStream;Impo
accessed by subsequent Programs.Each file is placed directly in the file system, and the absolute filename contains the file name and all path names, which can be seen at the operating system Level. From a certain point of view, the Java Virtual machine can also be regarded as some kind of operating System.File classM
Listfiles () of the Files class. For example File[] listFiles(FileFilter filter) , where FileFilter is the filter interface, you need to implement the interface to filter the files.The common filtering method is based on the file name, in fact, also support other filter conditions, such as whether readable, size is greater than 5M, and so on.Import java.io.*;PublicClassFilter1 {PublicStaticvoidMain(string[
writer:bysocket (mud and brick pulp carpenter) Micro-Blog: Bysocket Watercress: Bysocket FaceBook: Bysocket Twitter: Bysocket Remember Java source code is set to start looking, wrote a series of related articles, received a good evaluation. Thank you, readers. I will still read the old writing to the old , and vivid image of the writing to experience. This is still a diagram , I study io this piece. the m
JAVA 48th-IO stream (2): File Replication Buffer Zone 1, javaio
1. Copy a text file
Copy the text file from disk G to disk D.
That is, read the data of text files in the G drive and write the data to drive D-> write-in-connection
The cut is to delete the
called for a specific file, a null pointer is thrown.
File F = new file ("C: \ ABC ");
String [] names = f. List ();
Print the directory cyclically Using Recursion
Attention should be paid to recursion
1. Restrictions
2. Pay attention to the number of recursion times to avoid memory overflow.
Delete an object
Directory with content, delete from the inside out
Re
Directory:
1. Move a file/rename
2. delete an object
3. List Files in the directory
1. Move a file/rename
Package mjn. io; import Java. io. file;/*** file operation: Move the
" folder:Import java.io.File; public class createdir { publicstaticvoid main (String args[]) { = "/tmp/ User/java/bin "; New File (dirname); // Create directory now d.mkdirs (); }}Compile and execute the above code to create the directory "/tmp/user/java/bin".note: Java automatically disting
O (∩_∩) o haha ~1. OverviewA mature language must have several modules: IO, Communication, threading, UI ...Java as a mature programming language, its IO stream is more complex. Last picture everyone feels the following:For a simple analysis, Io is divided into two streams: a character stream and a stream of bytes. The
.
Console input and output:Version after JDK 5 We can also use the Java Scanner class to get input from the console.Read and write files:FileInputStreamMethod 1: You can use the file name of the string type to create an input stream object to read the fileNew FileInputStream ("C:/java/hello");Method 2: You can also use a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.