About 19,300,000 results
Open links in new tab
  1. Different ways of Reading a text file in Java - GeeksforGeeks

    Jan 4, 2025 · There are several ways to read a plain text file in Java e.g. you can use FileReader, BufferedReader, or Scanner to read a text file. Every utility provides something special e.g. BufferedReader provides buffering of data for fast reading, and Scanner provides parsing ability.

  2. Java Read Files - W3Schools

    Read a File. In the previous chapter, you learned how to create and write to a file. In the following example, we use the Scanner class to read the contents of the text file we created in the previous chapter:

  3. Reading a plain text file in Java - Stack Overflow

    The most simple way to read data from a file in Java is making use of the File class to read the file and the Scanner class to read the content of the file.

  4. Reading a .txt file using Scanner class in Java - Stack Overflow

    Use following codes to read the file. public static void main(String[] args) { try { System.out.print("Enter the file name with extension : "); Scanner input = new Scanner(System.in); File file = new File(input.nextLine()); input = new Scanner(file); while (input.hasNextLine()) { String line = input.nextLine(); System.out.println(line);

  5. Reading a text file in java - Stack Overflow

    Try the Scanner class which no one knows about but can do almost anything with text. To get a reader for a file, use. File file = new File ("...path..."); String encoding = "...."; // Encoding of your file. new FileInputStream (file), encoding)); ... use reader ...

  6. How to Read a File in Java - Baeldung

    Jan 8, 2024 · In this tutorial, we’ll explore different ways to read from a File in Java. First, we’ll learn how to load a file from the classpath, a URL, or from a JAR file using standard Java classes. Second, we’ll see how to read the content with BufferedReader, Scanner, StreamTokenizer, DataInputStream, SequenceInputStream, and FileChannel. We will ...

  7. Java Program to Read a File to String - GeeksforGeeks

    Oct 10, 2022 · There are several ways to read a plain text file in Java e.g. you can use FileReader, BufferedReader or Scanner to read a text file. Given a text file, the task is to read the contents of a file present in a local directory and storing it in a string.

  8. How to Read and Write Text File in Java - CodeJava.net

    Jul 28, 2019 · In this tutorial, we show you how to read from and write to text (or character) files using classes available in the java.io package. First, let’s look at the different classes that are capable of reading and writing character streams. 1. Reader, InputStreamReader, FileReader and BufferedReader.

  9. Java read text file - DigitalOcean

    Aug 3, 2022 · There are many ways to read a text file in java. A text file is made of characters, so we can use Reader classes. There are some utility classes too to read a text file in java. Java read text file using Files class; Read text file in java using FileReader; Java read text file using BufferedReader; Using Scanner class to read text file in java

  10. Java read text files - FileReader, InputStreamReader ... - ZetCode

    Jul 10, 2024 · Java read text files tutorial shows how to read text files in Java. We use build-in tools including FileReader, InputStreamReader, and Scanner.

  11. Some results have been removed
Refresh