Update Files.java
This commit is contained in:
		@@ -224,6 +224,10 @@ public class Files {
 | 
			
		||||
        return Optional.ofNullable(readFromURL(url)).orElse(def);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String readFromURL(String url,  Charset charset, String def) {
 | 
			
		||||
        return Optional.ofNullable(readFromURL(url, charset)).orElse(def);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String readFromURL(String url) {
 | 
			
		||||
        try (InputStream inputStream = new URL(url).openStream(); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
 | 
			
		||||
            return new String(IO.readFully(bufferedInputStream));
 | 
			
		||||
@@ -233,6 +237,15 @@ public class Files {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String readFromURL(String url, Charset charset) {
 | 
			
		||||
        try (InputStream inputStream = new URL(url).openStream(); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
 | 
			
		||||
            return new String(IO.readFully(bufferedInputStream), charset);
 | 
			
		||||
        } catch (Throwable t) {
 | 
			
		||||
            t.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String readFromFile(File file) {
 | 
			
		||||
        return readFromFile(file, 1024, StandardCharsets.UTF_8);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user