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
package com.loya.onetomanybidirectionaldemo.controller; | |
import com.loya.onetomanybidirectionaldemo.entity.Author; | |
import com.loya.onetomanybidirectionaldemo.entity.Book; | |
import com.loya.onetomanybidirectionaldemo.service.AuthorService; | |
import com.loya.onetomanybidirectionaldemo.service.BookService; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.MediaType; | |
import org.springframework.web.bind.annotation.*; |
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
private ArrayList<String[]> readXcelDocuments(InputStream file) throws Exception { | |
ArrayList<String[]> trans = new ArrayList<String[]>(); | |
Workbook workbook = WorkbookFactory.create(file); | |
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); | |
//Get first sheet from the workbook | |
Sheet sheet = workbook.getSheetAt(0); |
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
public static List<String> getFile(String filePath) throws IOException { | |
BufferedReader br = | |
new BufferedReader(new FileReader | |
(filePath)); | |
List<String> lines = new ArrayList<String>(); | |
// Read file line by line | |
String line = ""; |
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
public static List<String> getFile(String filePath) throws IOException { | |
BufferedReader br = | |
new BufferedReader(new FileReader | |
(filePath)); | |
List<String> lines = new ArrayList<String>(); | |
// Read file line by line | |
String line = ""; |
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
<dependencies> | |
<!--Apache POI dependency fo reading and writing microsoft docs --> | |
<dependency> | |
<groupId>org.apache.poi</groupId> | |
<artifactId>poi</artifactId> | |
<version>3.17</version> | |
</dependency> | |
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> |
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
/** | |
* A helper method to convert a Multipart File to a java.io file | |
* | |
* @param file a Multipart file to be converted | |
* @return a java.io File | |
* @throws IOException | |
*/ | |
public static File convertMultipartFile(MultipartFile file) throws IOException { | |
File convertedFile = new File(file.getOriginalFilename()); | |
convertedFile.createNewFile(); |
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
public class SplitWordWithSpecialCharacter { | |
public String keyword; | |
public String word; | |
public SplitWordWithSpecialCharacter(String line) { | |
String[] split = line.split("="); | |
this.keyword = split[0]; | |
this.word = split[1]; | |
} |
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
public void extractMultipartFile(MultipartFile file){ | |
InputStream inputStream =file.getInputStream(); | |
String originalFileName = file.getOriginalFilename(); | |
String fileName = file.getName(); | |
byte[] bytes = file.getBytes(); | |
String contentType = file.getContentType(); | |
} |