{"id":65846,"date":"2021-07-16T04:10:05","date_gmt":"2021-07-16T08:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/scjp-basic-java-i-o-java-short-notes-scjp\/"},"modified":"2022-05-28T19:53:50","modified_gmt":"2022-05-28T23:53:50","slug":"scjp-basic-java-i-o-java-short-notes-scjp","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65846","title":{"rendered":"SCJP: Basic Java I\/O #Java Short Notes #SCJP"},"content":{"rendered":"<ul>\n<li> ByteStream is the basic I\/O stream. Handles data as           a stream of bytes. Does operation with byte unit and          uses 8 bit. FileInputStream, FileOutputStream &#8211; can           be used to copy files as byte by byte.     <\/li>\n<li> Character Streams: FileReader and FileWriter are           character streams. They treat file data as 16 bit           unicode charater streams.     <\/li>\n<li> InputStreamReader, OutputStreamWriter are also           character streams. May be used in socket data           reading.     <\/li>\n<li> Line-Oriented I\/O: BufferedReader and PrintWriter     <\/li>\n<li> Buffered Streams: BufferedInputStream and           BufferedOutputStream create buffered byte streams,           while BufferedReader and BufferedWriter create           buffered character streams     <\/li>\n<li> You can set autoflush()  of buffered streams or           call manually flush() method.    <\/li>\n<li> The scanner API breaks input into individual          tokens. The formatting API assembles data into          nicely formatted, human-readable form.    <\/li>\n<li> Scanner:\n<pre>Scanner scanner = new Scanner(new BufferedReader(new FileReader(\"test.txt\")));            while (s.hasNext()) {                System.out.println(s.next());            }<\/pre>\n<\/li>\n<li> To create formatted output streams, instantiate          PrintWriter not PrintStream    <\/li>\n<li> Check: System.out.format(&#8220;The square root of %d is %f.%n&#8221;, i, r);     <\/li>\n<li> System.out and System.err are            PrintStream objects. PrintStream is really a byte           stream but uses some mechanism to emulate           character stream.     <\/li>\n<li> InputStreamReader cin = new InputStreamReader(System.in); System.in is a byte stream. InputStreamReader is used to emulate a character stream.    <\/li>\n<li> System.console provides character streams to handle         console read\/write operations. Provides readPassword  method to read password from the console     <\/li>\n<li>Data Streams: Support I\/O operations of primitive          data types. DataInputStream and DataOutputStream.     <\/li>\n<li> Check:\n<pre>out = new DataOutputStream(new            BufferedOutputStream(new FileOutputStream(dataFile)));out.writeDouble(prices);out.writeInt(units);out.writeUTF(descs);<\/pre>\n<\/li>\n<li> DataStreams detects an end-of-file condition by catching EOFException<\/li>\n<li>Correct type to represent currency values: java.math.BigDecimal &#8211; an object type<\/li>\n<li>Object Streams: ObjectInputStream and ObjectOutputStream. Use writeObject and readObject to write and read objects respectively.<\/li>\n<li> A stream can contain only one copy of an object but many references to it when required.<\/li>\n<li> <a href='http:\/\/java.sun.com\/docs\/books\/tutorial\/essential\/io\/file.html' target='new' rel=\"noopener\">File Objects: File I\/O<\/a><\/li>\n<li> Random access file:\n<pre>new RandomAccessFile(\"test.txt\", \"r\");new RandomAccessFile(\"test.txt\", \"rw\");RandomAccessFile methods:    * int skipBytes(int)     * void seek(long)      * long getFilePointer() <\/pre>\n<\/li>\n<li> The new java.nio.*  package provides supports to handle      file i\/o for high performance applications.  <\/li>\n<\/ul>\n<p> From: http:\/\/sitestree.com\/?p=4878<br \/> Categories:Java Short Notes, SCJP<br \/>Tags:<br \/> Post Data:2012-10-24 02:25:07<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ByteStream is the basic I\/O stream. Handles data as a stream of bytes. Does operation with byte unit and uses 8 bit. FileInputStream, FileOutputStream &#8211; can be used to copy files as byte by byte. Character Streams: FileReader and FileWriter are character streams. They treat file data as 16 bit unicode charater streams. InputStreamReader, OutputStreamWriter &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65846\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917,1954],"tags":[],"class_list":["post-65846","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","category-scjp-ocjp","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":65864,"url":"http:\/\/bangla.sitestree.com\/?p=65864","url_meta":{"origin":65846,"position":0},"title":"SCJP Training: Lesson 3: API Contents #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"The Number Classes Characters Strings The StringBuilder Class Character Streams (FileReader, FileWriter) Buffered Streams (BufferedReader, BufferedWriter) Formatting (PrintWriter) File Objects (File) Data Streams Object Streams Manipulating Characters in a String (String split method) Methods of the Pattern Class Methods of the Matcher Class Scanning Formatting Formatting (PrintWriter, formatting parameters) Formatting\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22132,"url":"http:\/\/bangla.sitestree.com\/?p=22132","url_meta":{"origin":65846,"position":1},"title":"SCJP: Sun Certified Java Programmer: All that you need to know #SCJP","author":"Sayed","date":"March 10, 2021","format":false,"excerpt":"Introduction to Sun Certified Java Programmer Certification CourseJava : SCJP: Important ResourcesJAVA: Some links: useful for exams like scjp\/scjaSCJP Essential KnowledgeSCJP Practice ExamsSCJP Training: Lesson 1: Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65836,"url":"http:\/\/bangla.sitestree.com\/?p=65836","url_meta":{"origin":65846,"position":2},"title":"SCJP: Flow controls and exception #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"Flow Control and ExceptionsFlow control statements Conditional: if, if-else and switch-case Looping: for, while, do-while Exception handling: try-catch-finally, throw Ad hoc flow control: break, continue with or without labelsswitch statement switch(expression){ case ConstantExpression: statement(s); case ConstantExpression: statement(s); . . . default: statement(s); } expression: must be char, byte, short, or\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65822,"url":"http:\/\/bangla.sitestree.com\/?p=65822","url_meta":{"origin":65846,"position":3},"title":"SCJP: Language Fundamentals #Java Short Notes #SCJP","author":"Sayed","date":"July 15, 2021","format":false,"excerpt":"Class declaration and java source file. Only \"one\" top-level public class is allowed per java source file. The name of the java source file and the name of the top-level public class MUST be the same. If no public class is there in a file, after compiling separate class files\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65816,"url":"http:\/\/bangla.sitestree.com\/?p=65816","url_meta":{"origin":65846,"position":4},"title":"JAVA: Some links: useful for exams like scjp\/scja #Java Short Notes #SCJP #Blog","author":"Sayed","date":"July 15, 2021","format":false,"excerpt":"Assertions in Java: http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/guide\/lang\/assert.html Enum in Java:http:\/\/www.java2s.com\/Code\/Java\/Language-Basics\/Enum.htmStringBuffer and StringBuilder Classes have similar methods where StringBuffer is synchronized: http:\/\/java.sun.com\/j2se\/1.5.0\/docs\/api\/java\/lang\/StringBuilder.htmlSerialize and Deserialize: http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/io\/Serializable.htmljava.util package is very important: http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/package-summary.html From: http:\/\/sitestree.com\/?p=4845 Categories:Java Short Notes, SCJP, BlogTags: Post Data:2013-06-11 18:38:25 Shop Online: https:\/\/www.ShopForSoul.com\/ (Big Data, Cloud, Security, Machine Learning): Courses: http:\/\/Training.SitesTree.com In Bengali: http:\/\/Bangla.SaLearningSchool.com\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26864,"url":"http:\/\/bangla.sitestree.com\/?p=26864","url_meta":{"origin":65846,"position":5},"title":"Example Java Programs #Programming Code Examples #Java\/J2EE\/J2ME #J2SE","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"Very Simple Java Example Programs HelloWorld.java public class HelloWorld { \/\/ method main(): ALWAYS the APPLICATION entry point public static void main (String[] args) { System.out.println (\"Hello World!\"); } } \/\/ Print Today's Date import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println (\"Hello, it's:\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65846"}],"version-history":[{"count":2,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65846\/revisions"}],"predecessor-version":[{"id":74740,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65846\/revisions\/74740"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65846"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}