• 17 September

    How to Get String Between Two Characters in Java

    In this post, we will see How to get String between two characters in java. Ways to get String between two characters in java. There are multiple ways to How to get String between two characters in java Using String’s substring() method To get String between two characters in java, use String’s substring() method. Find […]

  • 17 September

    Check if Date Is Weekend or Weekday in Java

    In this post, we will see how to check if Date is weekend or weekday in Java. Please note that we will consider Saturaday/Sunday as weekend and rest five days of week as weekdays. Using LocalDate’s getDayOfWeek() method We can use LocalDate’s getDayOfWeek() method to check if given date is weekend or weekday in Java. […]

  • 16 September

    How to Remove Extension from Filename in Java

    In this post, we will see how to remove extension from filename in java. Ways to Remove extension from filename in java There are multiple ways to remove extension from filename in java. Let’s go through them. Using substring() and lastIndexOf() methods You can first find last index of dot(.) using String’s lastIndexOf() method and […]

  • 16 September

    How to Write Array to File in Java

    In this post, we will see how to write array to file in java. Ways to Write Array to File in Java There are different ways to write array to file in java. Let’s go through them. Using BufferWriter Here are steps to write array to file in java: Create new FileWriter and wrap it […]

  • 16 September

    How to Take Integer Input in Java

    This article discusses the methods to take the integer input in Java. Variables In programs, data values are reserved in memory locations that can be identified by names (identifiers). Such named memory location which temporarily reserves data that can be changed while the program is running is called a variable. Let’s see how variables are […]

  • 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-6339ebcfa2d16150172466/] Output: [crayon-6339ebcfa2d1b526452726/] 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-6339ebcfa3284134888928/] [crayon-6339ebcfa3289203129850/] 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-6339ebcfa3741229168012/] [crayon-6339ebcfa3747523938561/] 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 […]