About 487,000 results
Open links in new tab
  1. Reading a plain text file in Java - Stack Overflow

    I documented 15 ways to read a file in Java and then tested them for speed with various file sizes - from 1 KB to 1 GB and here are the top three ways to do this: java.nio.file.Files.readAllBytes() Tested to work in Java 7, 8, and 9.

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

    The file you read in must have exactly the file name you specify: "10_random" not "10_random.txt" not "10_random.blah", it must exactly match what you are asking for. You can change either one to match so that they line up, but just be sure they do.

  3. read complete file without using loop in java - Stack Overflow

    Jan 5, 2013 · How to create a Java String from the contents of a file Whole text file to a String in Java. I am trying to read the contents of a file using FileReader . But i want to read the file without reading a line by line . Is it possible to read the whole file without loop. I …

  4. How can I read all files in a folder from Java? - Stack Overflow

    Feb 16, 2024 · import java.io.File; public class ReadFilesFromFolder { public static File folder = new File("C:/Documents ...

  5. Reading a text file in java - Stack Overflow

    How would I read a .txt file in Java and put every line in an array when every lines contains integers, strings, and doubles? And every line has different amounts of words/numbers.

  6. java - Best way to read data from a file - Stack Overflow

    Aug 16, 2011 · Possible Duplicate: Best way to read a text file. In Java I can open a text file like this: BufferedReader reader = new BufferedReader(new FileReader("file.txt")); My question is, how do you read from the following file? The first line is a number (830) representing number of words, and the following lines contain the words.

  7. java - How do I load a file from resource folder? - Stack Overflow

    Read File as java.io.File. Alternatively, if you need an instance of java.io.File, you can employ the getResource() method to retrieve the resource as a URL, and create a File from the resource's path or URI. However, using the URI requires handling the URISyntaxException.

  8. How do I create a Java string from the contents of a file?

    Read all text from a file. Java 11 added the readString() method to read small files as a String, preserving line terminators:

  9. How to read json file into java with simple JSON library

    Jun 7, 2012 · This is the java code I wrote to read this file: package javaapplication1; import java.io ...

  10. java - What’s the best way to load a JSONObject from a json text …

    Nov 15, 2015 · I'm not a Java dev and haven't got time right now to look into it, but you may want to look at the rejected suggested edit to this post that purported to fix a race condition in your code here (as I understand it, file.json might get deleted between the f.exists() call and reading from the file, so using a try/catch is better) and consider implementing the change.

Refresh