Beruflich Dokumente
Kultur Dokumente
Working:
Serialization does not care about access modifiers of the field such
as private. All non transient and non static fields are considered part
of an object's persistent state and are eligible for serialisation.
We can assign values to final fields in conscrutors only and
serialization process do not invoke any constructor but still it can
assign values to final fields.
Introduction:
A stream can be defined as a sequence of data.
Java provides I/O Streams to read and write data where, a Stream represents an
input source or an output destination which could be a file, i/o devise, other program
etc.
In general, a Stream will be an input stream or, an output stream.
Based on the data they handle there are two types of streams −
Byte Streams
Character
Standard Streams
In Java, 3 streams are created for us automatically. All these streams are attached with
the console.
Conclusion
A Java stream acts as a file handling wrapper that operates according to the corresponding
I/O constructs. In many cases, character-oriented stream classes and byte-oriented stream
classes function in a very similar fashion. But, that does not mean that they
are not different. The stream classes defined in the java.io packages are rather simple and
unsophisticated, but they do serve their purpose.
import java.io.*;
import java.util.*;
class WriteText
{
public static void main(String[] args)
{
try {
String text = "Your sample content to save in a text
file.";
BufferedWriter out = new BufferedWriter(new
FileWriter("sample.txt"));
out.write(text);
out.close();
}
catch (IOException e)
{
System.out.println("Exception ");
}
return ;
No. String StringBuffer
2 String is slow and StringBuffer is fast and consumes less memory when you cancat st
) consumes more
memory when you
concat too many
strings because
every time it
creates new
instance.
3 String class StringBuffer class doesn't override the equals() method of Object c
) overrides the
equals() method of
Object class. So
you can compare
the contents of two
strings by equals()
method.
}
}
Difference between String and
StringBuffer
There are many differences between String and StringBuffer. A list of differences
between String and StringBuffer are given below:
omparison Chart
What is a String Class?
Java URL
The Java URL class represents an URL. URL is an acronym for Uniform Resource
Locator. It points to a resource on the World Wide Web. For example:
1. https://www.javatpoint.com/java-tutorial
Method Description
public URLConnection it returns the instance of URLConnection i.e. associated with this URL.
openConnection()
5. No Installation
A pure JDBC technology-based driver does not require special
installation.
GET Method
The GET method sends the encoded user information appended to the page
request. The page and the encoded information are separated by
the ? (question mark) symbol as follows −
POST Method
A generally more reliable method of passing information to a backend
program is the POST method. This packages the information in exactly the
same way as GET method, but instead of sending it as a text string after a ?
(question mark) in the URL it sends it as a separate message. This message
comes to the backend program in the form of the standard input which you
can parse and use for your processing. Servlet handles this type of requests
using doPost() method.