• 16 September

    Convert String to Path in Java

    In this post, we will see how to convert String to Path in Java. Using Paths’get() method [ Java 7 ] To convert String to Path, use jva.nio.file.Paths's get() method. It is a static method. Here is an example: [crayon-673f295509710416184445/] Output: [crayon-673f295509717361748106/] You can also join multiple strings using Paths‘s get() method. It will join […]

  • 15 September

    How to Replace Space with Underscore in Java

    Learn about how to replace space with underscore in java. Replace space with underscore in java 1. Using replace() method Use String’s replace() method to replace space with underscore in java. String’s replace() method returns a string replacing all the CharSequence to CharSequence. Syntax of replace() method: [crayon-673f2955099ac970157104/] [crayon-673f2955099b0592679068/] Output: This_blog_is_Java2blog As you can see, […]

  • 15 September

    How to Replace Comma with Space in Java

    Learn about how to replace comma with space in java. Replace comma with space in java 1. Using replace() method Use String’s replace() method to replace comma with space in java. Here is syntax of replace() method: [crayon-673f295509a94372408136/] [crayon-673f295509a97252005087/] Output: 1 2 3 4 As you can see, replace() method replaced each comma with space […]

  • 15 September

    How to Get Temp Directory Path in Java

    In this post, we will see how to get temp directory path in java. Get Temp Directory Path in Java Using System.getProperty() To get the temp directory path, you can simply use System.getProperty("java.io.tmpdir"). It will return default temporary folder based on your operating system. Default temp directory path Windows : %USER%\AppData\Local\Temp Linux/Unix: /tmp Let’s see […]

  • 11 June

    Remove Parentheses From String in Java

    Java uses the Strings data structure to store the text data. This article discusses methods to remove parentheses from a String in Java. Java Strings Java Strings is a class that stores the text data at contiguous memory locations. The String class implements the CharSequence interface along with other interfaces. Strings are a constant data […]

  • 25 May

    Get Variable Name as String in JavaScript

    1. Overview Retrieving a variable’s name as a string in JavaScript can be a handy technique in various programming scenarios, from debugging to dynamic property handling. We’ll explore several methods to convert variable names into strings, covering different use cases. Let’s consider a situation where we have a JavaScript variable, say myVar, and our objective […]

  • 25 May

    Format Date to yyyy-MM-dd in java

    In this post, we will see how to Format Date to yyyy-MM-dd in java. There are multiple ways to format Date to yyyy-MM-dd in java. Let’s go through them. Using DateTimeFormatter with LocalDate (Java 8) To Format Date to yyyy-MM-dd in java: Create a LocalDateTime object. Use DateTimeFormatter.ofPattern() to specify the pattern yyyy-MM-dd Call format() […]

  • 25 May

    Remove Comma from String in JavaScript

    In this post, we will see how to remove comma from String in Javascript. There are multiple ways to do it. Let’s go through them. Using replace() To remove comma from String in Javascript: Use replace() method with regular expression /\,/g as first parameter and empty string as second parameter. [crayon-673f29550a969060036132/] Output: [crayon-673f29550a96e589653420/] The replace() […]

  • 25 May

    Escape new line in JavaScript

    In this post, we will see how to escape new line in JavaScript. There is no well known JavaScript library which can escape all special characters in String. Escape new line in JavaScript To escape new line in JavaScript: Use replace() method with regular expression /[\n]/g as first parameter and \\n string as second parameter. […]