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
/** | |
* | |
* @author NguyenHaiDang@ActiveStudy | |
*/ | |
public class StringJoinerExample { | |
public static void main(String[] args) { | |
String s1 = "Hello"; | |
String s2 = "World"; | |
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
/** | |
* | |
* @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 | |
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
/** | |
* | |
* @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 | |
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
import java.util.StringJoiner; | |
/** | |
* | |
* @author NguyenHaiDang@ActiveStudy | |
*/ | |
public class StringJoinerExample { | |
public static void main(String[] args) { | |
StringJoiner sj = new StringJoiner(", "); |
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
import java.util.StringJoiner; | |
/** | |
* | |
* @author NguyenHaiDang@ActiveStudy | |
*/ | |
public class StringJoinerExample { | |
public static void main(String[] args) { |
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
//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()); |
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
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 | |
} |
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
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()); | |
} |
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
import com.activestudy.Utility.file.FileUtils; | |
import java.io.IOException; | |
import java.nio.file.*; | |
/** | |
* | |
* @author dangg | |
*/ |
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
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; | |