

{"id":101041,"date":"2022-05-30T09:00:30","date_gmt":"2022-05-30T03:30:30","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=101041"},"modified":"2026-05-30T16:33:10","modified_gmt":"2026-05-30T11:03:10","slug":"how-to-open-file-in-java","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/","title":{"rendered":"How to Open a File in Java?"},"content":{"rendered":"<p>We already know how to create a file in Java. Java also provides us with the provision to open and access the contents of a file. There are a total of six different ways in which we can open a file in Java. In this article, we will take a look at all those methods to open a file in Java.<\/p>\n<h3>Opening a file in Java<\/h3>\n<p>There are a total of six different ways to open a file in Java using different classes such as:<\/p>\n<ul>\n<li>Desktop class<\/li>\n<li>FileInputStream class<\/li>\n<li>BufferedReader class<\/li>\n<li>FileReader class<\/li>\n<li>Scanner class<\/li>\n<li>nio package<\/li>\n<\/ul>\n<p>Let us discuss them one by one at length.<\/p>\n<p>We have created a file with the name \u201cNewTextFile\u201d, in the location \u201cG:\\Internship\\NewTextFile.txt\u201d<\/p>\n<p>The file contains the following data:<br \/>\n\u201cThis is a tutorial on how to open a file in Java<br \/>\nDataFlair\u201d<\/p>\n<p>So, we will now open this file using different techniques.<\/p>\n<h3>Open file using Java Desktop class<\/h3>\n<p>The Java Desktop class contains an open() method that provides the provision to open a file in Java. It is part of the java.awt package. Although Java is a platform-independent language, the Java Desktop class is platform-dependent. We need to check the system for Desktop support before implementing this method. This class looks for an associated application on the Desktop of the system to handle the file.<\/p>\n<p>The class throws the FileNotFoundExeption, if there is no associated application or if the application fails to launch.<\/p>\n<ul>\n<li>This class launches the user\u2019s default browser to show a specific URL.<\/li>\n<li>It launches the user\u2019s default mail client with an optional mail-to URL.<\/li>\n<li>It launches the registered application to open, edit, or print a file.<\/li>\n<\/ul>\n<p>The open() method takes the file as an argument and launches the associated application to open the file.<\/p>\n<p><strong>The signature of the method is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public void open (File file) throws IOException  \r\n<\/pre>\n<h4>Exceptions thrown by the method:<\/h4>\n<ul>\n<li>If the file is null, it throws the NullPointerException.<\/li>\n<li>If the file does not exist, it throws the IllegalArgumentException.<\/li>\n<li>When there is no application associated with the given file type, it throws the IOException.<\/li>\n<li>If the current platform does not support the Desktop.Action.Open action, it throws the UnsupportedOperationExecution.<\/li>\n<\/ul>\n<p><strong>Code to open a file using the Desktop Class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.awt.Desktop;  \r\nimport java.io.*;  \r\npublic class DesktopClass\r\n{\r\n    public static void main(String[] args)   \r\n        {  \r\n        try  \r\n            {  \r\n            File file_open = new File(\"G:\\\\Internship\\\\NewTextFile.txt\");   \r\n            if(!Desktop.isDesktopSupported())\r\n            {  \r\n                System.out.println(\"Desktop Support Not Present in the system.\");  \r\n                return;  \r\n            }  \r\n            Desktop desktop = Desktop.getDesktop();  \r\n            if(file_open.exists())         \r\n                desktop.open(file_open);             \r\n        }  \r\n        catch(Exception e)  \r\n        {  \r\n            e.printStackTrace();  \r\n        }  \r\n        }  \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/desktop-method.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108962\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/desktop-method.webp\" alt=\"desktop method\" width=\"1920\" height=\"1032\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>So, we can see that the file is opened in the Notepad application, which is the default application of the system to open a text file.<\/p>\n<h3>Open the file using the Java FileInputStream class<\/h3>\n<p>The FileInputStream class present in the java.io package also helps in opening and reading a file. By using the constructor of this class, we can read a file in Java.<\/p>\n<p><strong>The signature of the FileInputStream constructor is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public FileInputStream(File file) throws FileNotFoundException  \r\n<\/pre>\n<p>This constructor takes a file as an argument. It throws FileNotFoundException if the file does not exist or if the file is a directory.<\/p>\n<p><strong>Code to understand the FileInputStream class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.io.*;  \r\nimport java.util.Scanner;  \r\npublic class FileInputStreamClass\r\n{\r\n    public static void main(String args[])  \r\n    {  \r\n        try  \r\n        {  \r\n            File file_create=new File(\"G:\\\\Internship\\\\NewTextFile.txt\");   \r\n            FileInputStream fin=new FileInputStream(file_create);\r\n            System.out.println(\"The content of the File are: \");  \r\n            int ch=0;  \r\n            while((ch=fin.read())!=-1)  \r\n            {  \r\n                System.out.print((char)ch); \r\n            }  \r\n        }  \r\n        catch(Exception e)  \r\n        {  \r\n            e.printStackTrace();  \r\n        }  \r\n    }  \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">The content of the File are:<br \/>\nThis is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<h3>Open the file using the Java BufferedReader class<\/h3>\n<p>The Java BufferedReader class reads characters from the character input stream. It is part of the java.io package. We can use the constructor of this class to open and read a file.<\/p>\n<p>When we open a file using the Java BufferedReader class, then the information of the file is displayed line by line instead of displaying each character. It increases the readability of the file . There is no explicit code required in the program to close the file it implicitly closes after processing is done. Java BufferedReader class is suitable to use when the files contain large amounts of information.<\/p>\n<p><strong>The signature of the constructor is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public BufferedReader(Reader in)  \r\n<\/pre>\n<p>The constructor throws the FileNotFoundException, if the file does not exist or is the name of a directory.<\/p>\n<p><strong>Code to understand the BufferedReader class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.io.*;  \r\nimport java.util.Scanner;  \r\npublic class BufferedReaderClass\r\n{\r\n    public static void main(String args[])  \r\n    {  \r\n        try  \r\n        {   \r\n            File file_open=new File(\"G:\\\\Internship\\\\NewTextFile.txt\");   \r\n            BufferedReader br=new BufferedReader(new FileReader(file_open));  \r\n            System.out.println(\"The content of the file are: \");  \r\n            int ch=0;  \r\n            while((ch=br.read())!=-1)  \r\n            {  \r\n            System.out.print((char)ch);  \r\n            }  \r\n        }  \r\n        catch(Exception e)  \r\n        {  \r\n            e.printStackTrace();  \r\n        }  \r\n    }  \r\n}\r\n<\/pre>\n<p><strong>The output of the above code is:<\/strong><\/p>\n<div class=\"code-output\">The content of the file are:<br \/>\nThis is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<h3>Open the file using the Java FileReader class<\/h3>\n<p>The Java FileReader class is also a part of the java.io package, and we can use it to read and open files as well. Using this class, we can read the raw bytes of a file. We use the constructor of the FileReader class to open and read a file.<\/p>\n<p>When we open a file using the Java BufferedReader class, the information of the file is displayed line by line instead of displaying each character. It increases the readability of the file. There is no explicit code required in the program to close the file; it implicitly closes after processing is done. Java BufferedReader class is suitable for use when the files contain large amounts of information.<\/p>\n<p><strong>The signature of the constructor is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public FileReader(File file) throws FileNotFoundException  \r\n<\/pre>\n<p>The constructor throws the FileNotFoundException, if the file does not exist or is the name of a directory.<\/p>\n<p><strong>Code to understand the FileReader class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.io.*;\r\npublic class FileReaderClass\r\n{\r\n    public static void main(String args[])  \r\n    {  \r\n        try  \r\n        {   \r\n            FileReader file_open=new FileReader(\"G:\\\\Internship\\\\NewTextFile.txt\");   \r\n            System.out.println(\"The contents of the file are: \");  \r\n            int ch=0;  \r\n            while((ch=file_open.read())!=-1)  \r\n            {  \r\n                System.out.print((char)ch);   \r\n            }  \r\n        }  \r\n        catch(Exception e)  \r\n        {  \r\n            e.printStackTrace();  \r\n        }  \r\n    }  \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">The contents of the file are:<br \/>\nThis is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<h3>Open a file using the Java Scanner class<\/h3>\n<p>The Java Scanner class is part of the Java utility package(java.util). It is also used to open and read files. The constructor of the scanner class takes the file as input and reads the file. If the file does not exist or if it is the name of a directory, the constructor throws the FileNotFoundException.<\/p>\n<p><strong>The signature of the constructor is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public scanner (File source) throws FileNotFoundException  \r\n<\/pre>\n<p><strong>Code to understand the Scanner class:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.io.File;\r\nimport java.util.*;\r\npublic class ScannerClass\r\n{\r\n    public static void main(String[] args)   \r\n    {   \r\n        try  \r\n        {  \r\n            File file_open=new File(\"G:\\\\Internship\\\\NewTextFile.txt\");   \r\n            Scanner sc = new Scanner(file_open); \r\n            System.out.println(\"The contents of the file are: \");\r\n            while (sc.hasNextLine())        \r\n            System.out.println(sc.nextLine());    \r\n        }  \r\n        catch(Exception e)  \r\n        {  \r\n            e.printStackTrace();  \r\n        }  \r\n    }   \r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">The contents of the file are:<br \/>\nThis is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<p><strong>Code to open a file using the Scanner class but without any loop:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.io.File;\r\nimport java.io.FileNotFoundException;\r\nimport java.util.Scanner;\r\npublic class ReadingEntireFileWithoutLoop\r\n{\r\n  public static void main(String[] args)throws FileNotFoundException\r\n  {\r\n    File file = new File(\"G:\\\\Internship\\\\NewTextFile.txt\");\r\n    Scanner sc = new Scanner(file);\r\n    sc.useDelimiter(\"\\\\A\");\/\/Using a custom character as a delimeter,in this case \"\\\\A\"\r\n    System.out.println(sc.next());\r\n  }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">This is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<h3>Open file using the NIO package<\/h3>\n<p>The java.nio package contains a method readAllLines(), which reads all lines from a file and bytes from the file are decoded into characters using the UTF-8 charset. The method returns all the lines of the file as a list.<\/p>\n<p><strong>The signature of the method is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public static List&lt;String&gt; readAllLines(Path path) throws IOException<\/pre>\n<p>Where path is the path of the File.<\/p>\n<p>The above method can also be written in a simpler way as:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">File.readAllLines(path, Standard CharSets.UTF_8)  \r\n<\/pre>\n<p>We will also need an empty list to store the data.<\/p>\n<p><strong>Collection.emptyList()<\/strong> is a method of the Collection class of java.util package. The method is used to obtain an empty list.<\/p>\n<p><strong>The signature of the method is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public static final &lt;T&gt; List &lt;T&gt; emptyList()  \r\n<\/pre>\n<p><strong>Code to understand the nio package and opening file in a List:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.util.*;   \r\nimport java.nio.charset.StandardCharsets;   \r\nimport java.nio.file.*;   \r\nimport java.io.*;   \r\npublic class nioPackage\r\n{\r\n    public static List&lt;String&gt; readFileInList(String file_Name)   \r\n    {   \r\n        List&lt;String&gt; lines = Collections.emptyList();   \r\n        try  \r\n        {   \r\n            lines=Files.readAllLines(Paths.get(file_Name), StandardCharsets.UTF_8);   \r\n        }   \r\n        catch (IOException e)   \r\n        {   \r\n            e.printStackTrace();   \r\n        }   \r\n        return lines;   \r\n    }   \r\n    public static void main(String[] args)   \r\n    {   \r\n        List list = readFileInList(\"G:\\\\internship\\\\NewTextFile.txt\");   \r\n        Iterator&lt;String&gt; iter = list.iterator();   \r\n        System.out.println(\"The contents of the file are: \");\r\n        while (iter.hasNext())       \r\n        System.out.println(iter.next());       \r\n    }   \r\n}  \r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">The contents of the file are:<br \/>\nThis is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<p><strong>Code to understand the nio package and open a file in a String:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.FileOpening;\r\nimport java.nio.file.*;\r\npublic class nioPackageString\r\n{\r\n  public static String openFileAsString(String fName)throws Exception\r\n  {\r\n    String contents = \"\";\r\n    contents = new String(Files.readAllBytes(Paths.get(fName)));\r\n    return contents;\r\n  }\r\n  public static void main(String[] args) throws Exception\r\n  {\r\n    String data = openFileAsString(\"G:\/\/Internship\/\/NewTextFile.txt\");\r\n    System.out.println(data);\r\n  }\r\n}\r\n<\/pre>\n<p><strong>The output of the above code:<\/strong><\/p>\n<div class=\"code-output\">This is a tutorial on how to open a file in Java<br \/>\nDataFlair<\/div>\n<h3>Conclusion<\/h3>\n<p>As we can see, there are many ways to read\/open a file. It all depends on the programmer\u2019s will, which method suits his purpose. In this article, we saw all the different ways in which we can open a file. We discussed each of these methods with proper examples and code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We already know how to create a file in Java. Java also provides us with the provision to open and access the contents of a file. There are a total of six different ways&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":108950,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[36736,36735,36739,36738,36740,36742,36741,26820,36737],"class_list":["post-101041","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-different-ways-to-open-a-file-in-java","tag-how-to-open-a-file-in-java","tag-open-a-file-using-bufferedreader-class-in-java","tag-open-a-file-using-fileinputstream-class-in-java","tag-open-a-file-using-filereader-class-in-java","tag-open-a-file-using-nio-package-in-java","tag-open-a-file-using-scanner-class-in-java","tag-open-file-in-java","tag-opening-file-using-java-desktop-class-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Open a File in Java? - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn different ways to open file in java using Desktop class,FileInputStream class, BufferedReader class,FileReader class, Scanner class etc\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Open a File in Java? - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn different ways to open file in java using Desktop class,FileInputStream class, BufferedReader class,FileReader class, Scanner class etc\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-30T03:30:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-30T11:03:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Open a File in Java? - DataFlair","description":"Learn different ways to open file in java using Desktop class,FileInputStream class, BufferedReader class,FileReader class, Scanner class etc","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:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/","og_locale":"en_US","og_type":"article","og_title":"How to Open a File in Java? - DataFlair","og_description":"Learn different ways to open file in java using Desktop class,FileInputStream class, BufferedReader class,FileReader class, Scanner class etc","og_url":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-05-30T03:30:30+00:00","article_modified_time":"2026-05-30T11:03:10+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"How to Open a File in Java?","datePublished":"2022-05-30T03:30:30+00:00","dateModified":"2026-05-30T11:03:10+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/"},"wordCount":1224,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp","keywords":["different ways to open a file in java","how to open a file in java","open a file using bufferedreader class in java","open a file using fileinputstream class in java","open a file using filereader class in java","open a file using nio package in java","open a file using scanner class in java","open file in java","opening file using java desktop class in java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/","url":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/","name":"How to Open a File in Java? - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp","datePublished":"2022-05-30T03:30:30+00:00","dateModified":"2026-05-30T11:03:10+00:00","description":"Learn different ways to open file in java using Desktop class,FileInputStream class, BufferedReader class,FileReader class, Scanner class etc","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/04\/open-a-file-in-java.webp","width":1200,"height":628,"caption":"open a file in java"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/how-to-open-file-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"How to Open a File in Java?"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/101041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=101041"}],"version-history":[{"count":8,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/101041\/revisions"}],"predecessor-version":[{"id":148542,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/101041\/revisions\/148542"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108950"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=101041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=101041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=101041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}