Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java read file to string

public String readFile(String filePath) {
    String result = "";
    try {
        result = Files.readString(Paths.get(filePath));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
Comment

load file as string java

public static String loadFileAsString(String path) {
  InputStream stream = YourClassName.class.getResourceAsStream(path);
  try {
    String result = new String(stream.readAllBytes());
    return result;
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java create new arraylist with elements 
Java :: java for increment by 2 
Java :: java create file in folder 
Java :: find number of occurrences of a substring in a string java 
Java :: how to get data from radio group in android 
Java :: assert throws exception java 
Java :: java get random 
Java :: java break 2 for loops 
Java :: copy elements of array in java 
Java :: collatz conjecture 
Java :: Duration class java 
Java :: create java gui intellij 
Java :: java subscript numbers 
Java :: reverse int array java 
Java :: has a relationship in java 
Java :: java convert date to localdate 
Java :: java get relative path 
Java :: mongodb java find all documents 
Java :: android double click to exit 
Java :: java check palindrome with string builder 
Java :: can interface have attributes java 
Java :: how to format a double in java to 2 decimal places 
Java :: java swing set icon to JFrame 
Java :: java print formatted string 
Java :: how to find selenium webelement java 
Java :: final finally finalize 
Java :: retrieving parent element from child aWebelement selenium java 
Java :: get index of element java 
Java :: calculate smallest angle difference 
Java :: java list to array 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =