Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Process API
Search
Jussi Pohjolainen
April 26, 2020
Technology
1
210
Process API
Simple examples how to execute shell commands using Java
Jussi Pohjolainen
April 26, 2020
Tweet
Share
More Decks by Jussi Pohjolainen
See All by Jussi Pohjolainen
Introduction to Python (under construction)
pohjus
0
1.8k
Sustainability in Web Development - How to Optimize React Apps?
pohjus
0
140
Modern software development and fundamentals of AI
pohjus
0
140
C / C++ - language
pohjus
1
480
TypeScript for JS Developers
pohjus
0
410
Introduction to SwiftUI (2025-04-22)
pohjus
0
240
Kotlin Coroutines
pohjus
0
530
Android HTTP Clients
pohjus
0
520
Introduction to Jetpack Compose
pohjus
2
890
Other Decks in Technology
See All in Technology
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
150
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
160
AIエージェントを開発しよう!-AgentCore活用の勘所-
yukiogawa
0
140
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
2
170
2人で作ったAIダッシュボードが、開発組織の次の一手を照らした話― Cursor × SpecKit × 可視化の実践 ― Qiita AI Summit
noalisaai
1
380
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
110
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
1
120
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
5k
Context Engineeringの取り組み
nutslove
0
320
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
2
250
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
100
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
Automating Front-end Workflow
addyosmani
1371
200k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
270
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Designing for humans not robots
tammielis
254
26k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
250
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
140
Prompt Engineering for Job Search
mfonobong
0
160
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
Properties API Jussi Pohjolainen
To store preferences • Simple API to • fetch •
store • key value pairs
import java.io.*; import java.util.*; class Main { public static void
main(String [] args) throws Exception { Properties prop = new Properties(); // set key and value prop.setProperty("fontSize", "24"); prop.setProperty("fontColor", "RGB(255,255,255)"); String optionalComments = "My preferences file"; prop.store(new FileWriter("./myfile.prop"), optionalComments); } }
myfile.prop #My preferences file #Sun Apr 26 10:56:55 EEST 2020
fontSize=24 fontColor=RGB(255,255,255)
Reading import java.io.*; import java.util.*; class Main { public static
void main(String [] args) throws Exception { Properties prop = new Properties(); prop.load(new FileReader("./myfile.prop")); System.out.println(prop.get("fontSize")); System.out.println(prop.get("fontColor")); } }
Storing XML import java.io.*; import java.util.*; class Main { public
static void main(String [] args) throws Exception { Properties prop = new Properties(); // set key and value prop.setProperty("fontSize", "24"); prop.setProperty("fontColor", "RGB(255,255,255)"); String optionalComments = "My preferences file"; prop.storeToXML(new FileOutputStream("./myfile.xml"), optionalComments); } }
myfile.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>My
preferences file</comment> <entry key="fontSize">24</entry> <entry key="fontColor">RGB(255,255,255)</entry> </properties>
Reading import java.io.*; import java.util.*; class Main { public static
void main(String [] args) throws Exception { Properties prop = new Properties(); prop.loadFromXML(new FileInputStream("./myfile.xml")); System.out.println(prop.getProperty("fontSize")); System.out.println(prop.getProperty("fontColor")); } }
Jackson
Jackson • Java classes to json mapping • External class
library, add dependency • You can use Jackson to save for example preferences file
Dependency <dependencies> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.10.3</version> </dependency> </dependencies>
Pojo public class Dog { private String name; public void
setName(String name) { this.name = name; } public String getName() { return this.name; } }
Main import com.fasterxml.jackson.databind.ObjectMapper; import java.io.*; class Main { public static
void main(String [] args) throws Exception { Dog spot = new Dog(); spot.setName("Spot"); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.writeValue(new File("./file.json"), spot); Dog temp = objectMapper.readValue(new File("./file.json"), Dog.class); System.out.println(temp.getName()); } }