Tuesday 9 April 2019

Add quotation at the start and end of each line of string word in Notepad++ and make array in java

1.Find (in regular expression mode):
        (.+)

        Replace with:
        "\1"
        This adds the quotes:
        "amit"        "programming "        "code "        "tech"        
 2.Find (in extended mode):
        \r\n

   Replace with (with a space after the comma, not shown):
        ,

  This converts the lines into a comma-separated list:
        "amit", "programming", "code", "tech"

Number format in indian style RS in java android

import java.text.Format;
import java.text.NumberFormat;
import java.util.Locale;

Code:-

Format format = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
     
Log.e("valueindianstyle",format.format("10000000"));

OUTPUT: Rs 1,00,00,000

Monday 1 April 2019

move a file into another directory location in android with java programmatically


/*move a file into another directory location in android with programmatically*/
   private void moveFile(File file, File dir, File deteleold) throws IOException {
    File newFile = new File(dir, file.getName());
    FileChannel outputChannel = null;
    FileChannel inputChannel = null;
    try {
        outputChannel = new FileOutputStream(newFile).getChannel();
        inputChannel = new FileInputStream(file).getChannel();
        inputChannel.transferTo(0, inputChannel.size(), outputChannel);
        inputChannel.close();
        file.delete();/*remove the file */
    } finally {
        if (inputChannel != null) inputChannel.close();
        if (outputChannel != null) outputChannel.close();
    }

}