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
200
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
Sustainability in Web Development - How to Optimize React Apps?
pohjus
0
95
Modern software development and fundamentals of AI
pohjus
0
92
C / C++ - language
pohjus
1
430
TypeScript for JS Developers
pohjus
0
370
Introduction to SwiftUI (2025-04-22)
pohjus
0
200
Kotlin Coroutines
pohjus
0
490
Android HTTP Clients
pohjus
0
480
Introduction to Jetpack Compose
pohjus
2
780
Java Exceptions
pohjus
0
300
Other Decks in Technology
See All in Technology
Terraform にコントリビュートしていたら Azure のコストをやらかした話 / How I Messed Up Azure Costs While Contributing to Terraform
nnstt1
1
480
20 Years of Domain-Driven Design: What I’ve Learned About DDD
ewolff
1
340
"発信文化"をどうやって計測する?技術広報のKPI探索記/How do we measure communication culture?
bitkey
3
250
クラウドネイティブ環境の脅威モデリング
kyohmizu
2
410
『ささAI』ネタづくりをささえるAI📝 (にぼしいわし担当:GIFTech2025)
masapyon1212
0
110
使えるデータ基盤を作る技術選定の秘訣 / selecting-the-right-data-technology
pei0804
5
1.1k
Новые мапы в Go. Вова Марунин, Clatch, МТС
lamodatech
0
2k
地に足の付いた現実的な技術選定から魔力のある体験を得る『AIレシート読み取り機能』のケーススタディ / From Grounded Tech Choices to Magical UX: A Case Study of AI Receipt Scanning
moznion
4
1.3k
DjangoCon Europe 2025 Keynote - Django for Data Science
wsvincent
0
550
Previewでもここまで追える! Azure AI Foundryで始めるLLMトレース
tomodo_ysys
2
660
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
7
64k
Compose におけるパスワード自動入力とパスワード保存
tonionagauzzi
0
210
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.1k
Embracing the Ebb and Flow
colly
85
4.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
120
52k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
The Cost Of JavaScript in 2023
addyosmani
49
7.8k
The Invisible Side of Design
smashingmag
299
50k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
790
Designing Experiences People Love
moore
142
24k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
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()); } }