A Pen by Massimo Cassandro on CodePen.
This file contains hidden or 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
{ | |
"type": "service_account", | |
"project_id": "XXXX", | |
"private_key_id": "XXXXXX", | |
"private_key": "-----BEGIN PRIVATE KEY-----\n+XXXXX-----END PRIVATE KEY-----\n", | |
"client_email": "<name of the service accnt>@<project-name>.iam.gserviceaccount.com", | |
"client_id": "1CXXXX", | |
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | |
"token_uri": "https://oauth2.googleapis.com/token", | |
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", |
This file contains hidden or 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
<svg display="none"> | |
<symbol id="icon-bell" viewBox="0 0 1024 1024"> | |
<title>bell</title> | |
<path class="path1" d="M97.6 758.4c20.8 11.2 60.8 27.2 132.8 38.4 12.8 1.6 25.6 4.8 40 6.4 11.2 123.2 116.8 220.8 243.2 220.8s230.4-97.6 243.2-220.8c12.8-1.6 25.6-3.2 38.4-6.4 60.8-11.2 107.2-24 137.6-43.2 24-14.4 40-36.8 46.4-62.4 6.4-27.2 0-56-16-78.4-4.8-6.4-8-11.2-12.8-16-3.2-3.2-4.8-6.4-8-9.6-1.6-1.6-1.6-3.2-3.2-4.8l-8-11.2c-54.4-70.4-91.2-118.4-91.2-276.8 0-166.4-147.2-302.4-328-302.4-88 0-171.2 32-233.6 89.6-60.8 57.6-94.4 132.8-92.8 211.2 0 156.8-36.8 204.8-91.2 276.8l-6.4 9.6c-6.4 8-12.8 16-17.6 22.4-1.6 3.2-4.8 6.4-6.4 9.6-17.6 22.4-24 52.8-17.6 81.6s25.6 51.2 51.2 65.6zM512 896c-51.2 0-96-33.6-110.4-80 35.2 1.6 72 3.2 108.8 3.2 38.4 0 75.2-1.6 112-3.2-14.4 46.4-59.2 80-110.4 80zM196.8 649.6c59.2-80 116.8-155.2 116.8-355.2 0-43.2 17.6-84.8 52.8-116.8 38.4-35.2 89.6-54.4 145.6-54.4 110.4 0 200 78.4 200 174.4 0 201.6 57.6 276.8 118.4 355.2l3.2 4.8c-14.4 4.8-35.2 9.6-60.8 14.4-72 12.8-164.8 19.2-260.8 19.2s-18 |
This file contains hidden or 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
@GetMapping("/reportFile") | |
@ApiOperation(produces = MediaType.APPLICATION_JSON_VALUE, httpMethod = "GET", response = String.class, | |
value = "GetAll feed back plans based on planMatch and cost", notes = "Sample note") | |
public void processFileAndOutput(HttpServletResponse res) { | |
//Read the file from an FTP server | |
//For now read it from the resource folder | |
// ApplicationHome home = new ApplicationHome(this.getClass()); | |
// File dir = home.getDir(); | |
// System.out.println("dfs"+dir); | |
Path filePath = Paths.get(System.getProperty("user.dir")+"/static/test.txt"); |
This file contains hidden or 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
@Service | |
public class FileService { | |
public List<FileReadDTO> readFileFromFTPAndGenerateObjects(Path path) throws IOException{ | |
List<FileReadDTO> list1 ; | |
try{ | |
Files.lines(path).forEach(item -> System.out.println(item)); | |
list1 = Files.lines(path).collect(new CustomFileCollector()); |
This file contains hidden or 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 CustomFileListCombiner implements BinaryOperator<List<FileReadDTO>> { | |
@Override | |
public List<FileReadDTO> apply(List<FileReadDTO> t, List<FileReadDTO> u) { | |
List<FileReadDTO> newList = new ArrayList<>(); | |
newList.addAll(t); | |
newList.addAll(u); | |
return newList; | |
} |
This file contains hidden or 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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.function.Supplier; | |
//FileReadDTO is the POJO class | |
public class CustomFileListSupplier implements Supplier<List<FileReadDTO>> { | |
@Override | |
public List<FileReadDTO> get() { |
This file contains hidden or 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
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import javax.servlet.Filter; |
This file contains hidden or 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 ByteArrayServletStream extends ServletOutputStream { | |
ByteArrayOutputStream baos; | |
ByteArrayServletStream(ByteArrayOutputStream baos) { | |
this.baos = baos; | |
} | |
@Override | |
public void write(int param) throws IOException { |
This file contains hidden or 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
/** | |
* IMplemented own Printer as the new wrapper | |
* | |
*/ | |
public class ByteArrayPrinter { | |
private ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
private PrintWriter pw = new PrintWriter(baos); |