) {livedata data=new livedata ();d ata.createdata ();d ata.readdata ();} public void Createdata () {try {outputstream=new bytearrayoutputstream ();D Ataoutputstream dataoutputstream=new DataOutputStream (OutputStream); for (int i = 0; I 8. Sometimes, we need to calculate the number of words in a document, or the control of the document into the control of the document content (Control/Query text/number). Java
longer readwhile ((N=fis.read (words))!=-1) {//6. Read the information in the file input stream until-1 endsFos.write (Words,0,n); 7. The file output stream is written to read the content length in the words array is 0-n}System.out.print ("File copy succeeded, view file");}catch (Filenotfoundexcepton e) {//The first input file may not be found here to write an exceptionE.prinntstacktrace (); Exceptions fro
efficient reading of characters, arrays, and rows.You can specify the size of the buffer, or you can use the default size. In most cases, the default value is large enough.1 //character buffer input stream2BufferedReader br =NewBufferedReader (NewFileReader ("A.txt"));3 intLen = 0;4 Char[] ch =New Char[1024];5 while(len = br.read (ch))! =-1){6System.out.println (NewString (Ch,0,len));//Print the contents of the a.txt in a string way7 }
also provides a way to read and write various types of methods, using a similar method, which is no longer elaborated here, interested friends can try on their own.Attention:
If you want to start reading from the file header, you must move the pointer to the head and seek () to assign the pointer to a position;
Read (byte[]) can pass through the byte array to which all the bytes are reading;
When a byte array is converted to a string, the encoding format of the primary string i
Java Collection Framework summary (5) use of The--map interfaceMap is used to hold data that has a mapping relationship (key-vlaue). The key of map does not allow repetition, that is, any two key of the same map object is always returned false by the Equals methodThe map con
create a file object specifying an abstract path nameTenFile File =NewFile ("E:"); One //get all content in the specified directory (file array) Afile[] Files =file.listfiles (); - //iterate through the array and determine if the condition is met - for(File f:files) { the if(F.isfile ()) { - if(F.getname (). EndsWith (". jpg")){ - System.out.println (F.getname ()); - } + } - } + } A}1 Packagecn.itcast_
?
How do I correctly determine if an object is a lambda?
Why does iterable not provide the stream () and Parallelstream () methods?
Using semaphore in the parallel stream method in Java 8 could lead to deadlocks, is this a bug?
Why is it not allowed to define a method inherited from Java.lang.Object as
Merge stream/Sequential stream (Sequenceinputstream):is to combine multiple input streams into a single Stream object.1 Public classSequenceinputstreamdemo {2 Public Static voidMain (string[] args)throwsException {3 //To create a sequential stream object4Sequenceinputstream in =NewSequenceinputstream (New
and close the channel in}Catch(Exception e) { - System.out.println (e.tostring ()); to } + } - } the *}3. Writing files1 PackageCom.newdream.class4;2 3 ImportJava.io.BufferedReader;4 ImportJava.io.BufferedWriter;5 ImportJava.io.File;6 ImportJava.io.FileWriter;7 ImportJava.io.StringReader;8 9 Public classChariowriter {Ten One //writes text to the specified file A - - Public StaticString data=
server side, it is used to send data to the client. Otherwise, it is used to send data to the server side.
3. Simple TCP network program
1 import java. io. outputStream; 2 import java.net. serverSocket; 3 import java.net. socket; 4 5 public class Example4 {6 public static void main (String [] args) throws Exception {7 new TCPServer (). listen (); // create the TCPServer object and call the listen () method 8
Concurrency boostStream in Java is similar to the idea of data analysis in Hadoop, except that Hadoop is large, using the computational ecology of multiple machines, while Java stream uses the process of analyzing a piece of data in a single computer with multiple CPUs. By using the Parrallel method to realize the parallel task, the
, array, operator, etc.), swing,awt, event mechanism, file input and output stream processing, etc.Difficulties: The understanding of object-oriented ideas (interfaces, classes, etc.), threading, socket network programming, etc.Video Tutorial recommended: Xinxin Sun Java Basic Video tutorial, Zhang Xiaoxiang Java Basic Video tutorial, speak very thin, and the two
Map is a data storage method. In my personal opinion, it is an array in php or asp.net and can be directly used for Traversing arrays. However, there are many inherent methods for Traversing map in java, let's take a look at some instances.
The traversal Map method can be divided into two types:
One type is
introduces repeated annotations so that the same annotations can be declared multiple times in the same place. The Repeatable annotation is required. Java 8 is optimized at the compiler layer, and the same annotation is saved as a set, so the underlying principle remains unchanged.
5. Support for extended annotations
Java 8
Java core technology-New Features of Java 8-Lambda expressions1. General description
Java 8 new featuresFunctional InterfaceLambda expressions (closures)2 Java 8 new features
Oracle rel
to determine whether the original file at the end.1 Public classFileIO {2 Public Static voidMain (string[] args)throwsIOException {3String filename= "D:" +file.separator+ "Io.txt";4File file=NewFile (FileName);5InputStream inputstream=Newfileinputstream (file);6 byte[] by=New byte[1024];7 intCount=0;8 intTemp=0;9 while((Temp=inputstream.read ())!=-1){TenBy[count++]= (byte) temp; One A } - inputstream.close (); -SYSTEM.OUT.PRINTLN ("read-in length
* Copy of text files can be achieved using FileReader and FileWriter.* For non-text files (video files, audio files, pictures), only the byte stream can be used!1 @Test2 Public voidTestfilereader () {3FileReader FR =NULL;4 Try {5File File =NewFile ("Dbcp.txt");6FR =Newfilereader (file);7 Char[] C =New Char[24];8 intLen;9 while(len = Fr.read (c))! =-1){TenStr
I/O flow
Grouped by data into byte stream and character streams (coded table, Western ASCII, China gb2312 expansion for gbk--> Unified for Unicode--> optimization utf-8)Character streams are based on the byte stream, specifying what table to look forThe flow is divided into input and output streams.Common base class: byte s
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.