Created
February 16, 2018 17:44
-
-
Save ayoolaao/d9e62805ede79b71c9e000e1b575cf54 to your computer and use it in GitHub Desktop.
lambda exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.java.io; | |
import java.io.IOException; | |
import java.nio.file.*; | |
public class JavaIO { | |
static String dir = "./"; | |
static String text = "./UX_resume_nlb.txt"; | |
public static void main(String[] args){ | |
//TODO | |
try { | |
// walkDirectory(dir); | |
// deleteFile(dir); | |
System.out.println(readFile(text).toString()); | |
} catch (Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
public static void walkDirectory(String path) throws IOException{ | |
Files.walk(Paths.get(path)).forEach(f -> System.out.println(f.toFile())); | |
} | |
public static void deleteFile(String path) throws IOException{ | |
Files.delete(Paths.get(path)); | |
} | |
public static StringBuffer readFile(String path) throws IOException{ | |
StringBuffer content = new StringBuffer(); | |
// Files.lines(Paths.get(path)).forEach(l -> System.out.println(l)); | |
// Files.lines(Paths.get(path)).forEach(System.out::println); | |
Files.lines(Paths.get(path)).forEach(l -> content.append(l).append("\n")); | |
// Files.lines(Paths.get(path)).forEach(l -> content.append(l)); | |
// Files.lines(Paths.get(path)).forEach(content::append); | |
return content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Makes sense.