Skip to content

Instantly share code, notes, and snippets.

View dangnhdev's full-sized avatar

Nguyễn Hải Đăng dangnhdev

  • Hanoi, Vietnam
View GitHub Profile
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StringJoinerExample {
public static void main(String[] args) {
String s1 = "Hello";
String s2 = "World";
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StringJoinerExample {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
sb.append("Hello").append(" ").append("World"); //có thể nối liên tiếp
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StringJoinerExample {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.append("Hello").append(" ").append("World"); //có thể nối liên tiếp
import java.util.StringJoiner;
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StringJoinerExample {
public static void main(String[] args) {
StringJoiner sj = new StringJoiner(", ");
import java.util.StringJoiner;
/**
*
* @author NguyenHaiDang@ActiveStudy
*/
public class StringJoinerExample {
public static void main(String[] args) {
//tạo đường dẫn
Path base = Paths.get("C:/rafaelnadal/tournaments/2009");
//nối thêm file BNP.txt vào đường dẫn
Path path_1 = base.resolve("BNP.txt");
//output: C:\rafaelnadal\tournaments\2009\BNP.txt
System.out.println(path_1.toString());
//nối thêm file AEGON.txt vào đường dẫn
Path path_2 = base.resolve("AEGON.txt");
//output: C:\rafaelnadal\tournaments\2009\AEGON.txt
System.out.println(path_2.toString());
Path path01 = Paths.get("/rafaelnadal/tournaments/2009/BNP.txt");
Path path02 = Paths.get("C:/rafaelnadal/tournaments/2009/BNP.txt");
if(path01.equals(path02)){
System.out.println("The paths are equal!");
} else {
System.out.println("The paths are not equal!"); //true
}
try {
boolean check = Files.isSameFile(path01, path02);
if(check){
System.out.println("The paths locate the same file!"); //true
} else {
System.out.println("The paths does not locate the same file!");
}
} catch (IOException e) {
System.out.println(e.getMessage());
}
import com.activestudy.Utility.file.FileUtils;
import java.io.IOException;
import java.nio.file.*;
/**
*
* @author dangg
*/
import com.activestudy.Utility.file.FileUtils;
import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;