Intellij not showing GIT pull

This is a  problem which you faced when you have taken clone of your repository in your file explorer using tortoise git.

And then imported your project from file explorer to Intellij.
Like this


So to solve this problem follow these steps.

1. Enter alt+ctrl+S to open setting in intellij.

2. Find version control in the sidebar.

3.select your project which is not showing as part of the GIT.

4. Add your project in GIT.



122 total views, no views today

How to read from CSV file in Java

We can read data from a Microsoft Excel CSV file, where all the values will be column separated, to do this we will use a third party jar i.e OpenCSV.

OpenCSV

OpenCSV is a lightweight java CSV parser. OpenCSV provides most of the basic features for CSV parsing. Some of the important classes in OpenCSV parser are;

CSVReader: This is the most important class in OpenCSV. CSVReader class is used to parse CSV files. We can parse CSV data line by line or read all data at once.
CSVWriter: CSVWriter class is used to write CSV data to Writer implementation. 
CsvToBean: CsvToBean is used when you want to convert CSV data to java objects.
BeanToCsv: BeanToCsv is used to export Java beans to CSV file.

OpenCSV Maven Dependency

Add OpenCSV jar using below maven dependency in POM.XML file, please refer the latest version from https://mvnrepository.com/artifact/com.opencsv/opencsv
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.8</version>
</dependency>
There are two ways to read a csv file using OpenCSV
  1. Reading into an array of strings
  2. Reading into beans


Sample data :





Create java bean class to hold CSV data and all fields mention in POJO class should match the column name of CSV file and they are case sensitive.
package com.Excel;

import com.opencsv.bean.CsvBindByName;

public class Employee {
@CsvBindByName
private String Empid;
@CsvBindByName
private String name;
@CsvBindByName
private String salary;
@CsvBindByName
private String valid;

public String getEmpid() {
return Empid;
}
public void setEmpid(String empid) {
Empid = empid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getValid() {
return valid;
}
public void setValid(String valid) {
this.valid = valid;
}
}
we are using @CsvBindByName annotation which identify all columns by name in CSV file.

Main class to read our CSV file.

package com.Excel;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.List;
import com.opencsv.bean.CsvToBeanBuilder;

public class ReadEXcel {

@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) {
List<Employee> beans;
try {
beans = new CsvToBeanBuilder(new FileReader("test.csv")).withType(Employee.class).build().parse();
for (Employee employee : beans) {
System.out.println(employee.getEmpid());
System.out.println(employee.getName());
System.out.println(employee.getSalary());
}
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}

}
}

This jar gives us freedom of type conversions (wrapped and unwrapped primitives and Strings) occur automatically which is a big relief as a programmer you don’t bother about the type in excel as it will handle by your POJO class which you have created.




127 total views, no views today

The following untracked working tree files would be overwritten by checkout: .gitignore

Problem :

git.exe checkout master —

error: The following untracked working tree files would be overwritten by checkout:
.gitignore

Please move or remove them before you switch branches.
Aborting

Solution :

try running below commands one by one on your repository

git fetch --all

git reset --hard origin/master
this will reset your .gitignore file or any other file which is conflicting.
hope this helps .

176 total views, 2 views today

Git Storing credentials failed No password provided in eclipse

Problem : 
Storing credentials failed No password provided
I am trying to clone repository from the github while pull it ask for password Then, and i entered wrong password ans store in secure wallet of eclipse Now when I tried to fetch or pull i got the error “not authorized”
However, when I used the advice and clicked “Change Credentials” or “remove credentials” I received the following error:
“Storing credentials failed No password provided”
Solution :
if you are using eclipse then you can solve this problem by following these steps.
Preferences > General > Security > Secure Storage > Contents
delete everything from the content tab
Now try again to pull from repository
enter your correct password and store in secure wallet storage of eclipse.
Hope this will work for you.

142 total views, no views today