{"id":39817,"date":"2016-08-09T11:00:32","date_gmt":"2016-08-09T08:00:32","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=39817"},"modified":"2023-11-09T15:25:14","modified_gmt":"2023-11-09T13:25:14","slug":"java-nio-read-file-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/","title":{"rendered":"Java Nio Read File Example"},"content":{"rendered":"<p>With this example we are going to demonstrate how to use the Non-blocking I\/O API, or <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/package-summary.html\">NIO.2<\/a><\/code>\u00a0API (NIO API) for short, to read the contents of a file. The examples in this article are compiled and run in a Mac OS unix environment.<\/p>\n<p>Please note that Java SE 8 is required to run the code in this article.<br \/>\n<span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:515,&quot;3&quot;:{&quot;1&quot;:0},&quot;4&quot;:{&quot;1&quot;:2,&quot;2&quot;:16777215},&quot;12&quot;:0}\">[ulp id=&#8217;lQeyBcYaL5DqTMXI&#8217;]<\/span><\/p>\n<h2>1. Introduction to the NIO API<\/h2>\n<p>The <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/package-summary.html\">NIO.2<\/a><\/code> API was introduced in Java 7 as a replacement for the <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/io\/File.html\">java.io.File<\/a><\/code> class. It provides a flexible, and intuitive API for use with files.<\/p>\n<h2>2. Creating a NIO Path<\/h2>\n<p>In order to read a file from the file system we must first create a Path to the file.\u00a0\u00a0A <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/file\/Path.html\">Path<\/a><\/code> object is a hierarchical representation of the path on a system to the file or directory. The <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/file\/Path.html\">java.nio.file.Path<\/a><\/code> interface is the primary entry point for working with the <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/package-summary.html\">NIO 2<\/a><\/code> API.<\/p>\n<p>The easiest way to create a Path Object is to use the <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/nio\/file\/Paths.html\">java.nio.files.Paths<\/a><\/code> factory class. The class has a static <code>get()<\/code> method which can be used to obtain a reference to a file or directory. The method accepts either a string, or a sequence of strings(which it will join to form a path) as parameters. A <code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/file\/Path.html\">java.nio.file.Path<\/a><\/code> , like a <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/io\/File.html\">File<\/a><\/code>, may refer to either an absolute or relative path within the file system. \u00a0This is displayed in the following examples:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">Path p1 = Paths.get(\"cats\/fluffy.jpg\");\nPath p2 = Paths.get(\"\/home\/project\");\nPath p3 = Paths.get(\"\/animals\", \"dogs\", \"labradors\");\n<\/pre>\n<p>In the above:<\/p>\n<ul>\n<li>p1 creates a relative reference to a file in the current working directory.<\/li>\n<li>p2 creates a reference to an absolute directory in a Unix based system.<\/li>\n<li>p3 creates a reference to the absolute directory \/animals\/dogs\/labradors<\/li>\n<\/ul>\n<h2>3. Reading files with the NIO API<\/h2>\n<p>Once we have a Path Object we are able to execute most of the operations that were previously possible with <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/io\/File.html\">java.io.File<\/a><\/code>.<\/p>\n<h3>3.1 Using NIO API with newBufferedReader()<\/h3>\n<p>The\u00a0<code><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/package-summary.html\">NIO.2<\/a><\/code> API has methods for reading files using java.io streams. \u00a0The Files.newBufferedReader(Path,Charset) reads the file found at the Path location, using the specified Charset for character encoding. Here&#8217;s an example:<\/p>\n<pre class=\"brush:java\">Path path = Paths.get(\"src\/main\/resources\/shakespeare.txt\");\n    try(BufferedReader reader = Files.newBufferedReader(path, Charset.forName(\"UTF-8\"))){\n\n      \n      String currentLine = null;\n      while((currentLine = reader.readLine()) != null){\/\/while there is content on the current line\n        System.out.println(currentLine); \/\/ print the current line\n      }\n    }catch(IOException ex){\n      ex.printStackTrace(); \/\/handle an exception here\n    }\n<\/pre>\n<h3>3.2 Using NIO API with readAllLines()<\/h3>\n<p>Another option is to use the Files.readAll() method, which will read the contents of a file and return them as an ordered list of strings. Here&#8217;s an example of this method:<\/p>\n<pre class=\"brush:java\">    Path path = Paths.get(\"src\/main\/resources\/shakespeare.txt\");\n    try{\n\n      List contents = Files.readAllLines(path);\n\n      \/\/Read from the stream\n      for(String content:contents){\/\/for each line of content in contents\n        System.out.println(content);\/\/ print the line\n      }\n\n      }catch(IOException ex){\n      ex.printStackTrace();\/\/handle exception here\n    }\n<\/pre>\n<p><strong>NOTE:<\/strong> The readAllLines() method first commits the contents of the file to memory, as a result you may encounter an <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/OutOfMemoryError.html\">OutOfMemoryError<\/a><\/code> if there is too much content.[ulp id='lQeyBcYaL5DqTMXI']<\/p>\n<h3>3.3 Using NIO API with streams<\/h3>\n<p>With Java 8 came the introduction of streams in place of the previously used methods of iteration. This makes it easy to lazily load lines from a file, using memory in a piecemeal fashion, and therefore preventing the <code><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/OutOfMemoryError.html\">OutOfMemoryError<\/a><\/code> which was mentioned above. The example below shows how to make use of streams to achieve this:<\/p>\n<pre class=\"brush:java\">    Path path = Paths.get(\"src\/main\/resources\/shakespeare.txt\");\n    try {\n\n      Files.lines(path).forEach(System.out::println);\/\/print each line\n\n    } catch (IOException ex) {\n      ex.printStackTrace();\/\/handle exception here\n    }\n<\/pre>\n<p>Stream operations can be chained together into pipelines, which can make for some very powerful, declarative and concise code. For example, making use of the filter() operation on the above code in combination with the NIO API, allows us to to begin to analyse the contents of the file with ease.<\/p>\n<pre class=\"brush:java\">    Path path = Paths.get(\"src\/main\/resources\/shakespeare.txt\");\n    try {\n\n      Files.lines(path)\n           .filter(line -&gt; line.startsWith(\"Love\")) \/\/ this line filters any line out which does not meet the condition\n          .forEach(System.out::println);\/\/print each line\n\n    } catch (IOException ex) {\n      ex.printStackTrace();\/\/handle exception here\n    }\n<\/pre>\n<p>The example above shows how simply we are able to begin looking at Shakespeare&#8217;s lexical choices.<\/p>\n<h2>4. Summary<\/h2>\n<p>In this article we&#8217;ve introduced you several ways to use the NIO API to read a file from your file system. Along the way we&#8217;ve touched upon the Path object and let you know the benefits of using one method over another.<\/p>\n<h2>5. Download the Source Code<\/h2>\n<p>Below you can download the file read examples shown above:<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/08\/JavaNioReadFileExample.zip\"><strong>NIO API Read File Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The examples in this article are compiled and run in a Mac OS unix environment. Please note that Java SE 8 is required to run the code &hellip;<\/p>\n","protected":false},"author":99,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[189,1556,1555,1554,1557],"class_list":["post-39817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-core-java-2","tag-java-io-bufferedreader","tag-java-nio-file-files","tag-java-nio-file-path","tag-java-nio-file-paths"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Nio Read File Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Nio Read File Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-09T08:00:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-09T13:25:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Aaron Witter\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aaron Witter\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\"},\"author\":{\"name\":\"Aaron Witter\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2b00d6b192e2567295f989fb2878618d\"},\"headline\":\"Java Nio Read File Example\",\"datePublished\":\"2016-08-09T08:00:32+00:00\",\"dateModified\":\"2023-11-09T13:25:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\"},\"wordCount\":597,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\",\"java.io.BufferedReader\",\"java.nio.file.Files\",\"java.nio.file.Path\",\"java.nio.file.Paths\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\",\"name\":\"Java Nio Read File Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2016-08-09T08:00:32+00:00\",\"dateModified\":\"2023-11-09T13:25:14+00:00\",\"description\":\"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java Nio Read File Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2b00d6b192e2567295f989fb2878618d\",\"name\":\"Aaron Witter\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/Aaron-Witter-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/Aaron-Witter-96x96.jpg\",\"caption\":\"Aaron Witter\"},\"description\":\"Aaron is a self-taught Certified Oracle Java programmer, with experience delivering high quality Java applications for a variety of UK Government Departments. Aaron has worked on projects ranging from the overhaul of the National Statistics website to delivering a portal for quality management in the National Health Service.\",\"sameAs\":[\"http:\/\/examples.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/aaron-witter\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Nio Read File Example - Java Code Geeks","description":"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/","og_locale":"en_US","og_type":"article","og_title":"Java Nio Read File Example - Java Code Geeks","og_description":"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-08-09T08:00:32+00:00","article_modified_time":"2023-11-09T13:25:14+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Aaron Witter","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Aaron Witter","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/"},"author":{"name":"Aaron Witter","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2b00d6b192e2567295f989fb2878618d"},"headline":"Java Nio Read File Example","datePublished":"2016-08-09T08:00:32+00:00","dateModified":"2023-11-09T13:25:14+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/"},"wordCount":597,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java","java.io.BufferedReader","java.nio.file.Files","java.nio.file.Path","java.nio.file.Paths"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/","name":"Java Nio Read File Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2016-08-09T08:00:32+00:00","dateModified":"2023-11-09T13:25:14+00:00","description":"With this example we are going to demonstrate how to use the Non-blocking I\/O API, or NIO.2\u00a0API (NIO API) for short, to read the contents of a file. The","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/java-nio-read-file-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"Java Nio Read File Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2b00d6b192e2567295f989fb2878618d","name":"Aaron Witter","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/Aaron-Witter-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/Aaron-Witter-96x96.jpg","caption":"Aaron Witter"},"description":"Aaron is a self-taught Certified Oracle Java programmer, with experience delivering high quality Java applications for a variety of UK Government Departments. Aaron has worked on projects ranging from the overhaul of the National Statistics website to delivering a portal for quality management in the National Health Service.","sameAs":["http:\/\/examples.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/aaron-witter\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/39817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/99"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=39817"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/39817\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=39817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=39817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=39817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}