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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jussi Pohjolainen
April 26, 2020
Technology
220
1
Share
Process API
Simple examples how to execute shell commands using Java
Jussi Pohjolainen
April 26, 2020
More Decks by Jussi Pohjolainen
See All by Jussi Pohjolainen
Introduction to Python (under construction)
pohjus
0
1.9k
Sustainability in Web Development - How to Optimize React Apps?
pohjus
0
160
Modern software development and fundamentals of AI
pohjus
0
160
C / C++ - language
pohjus
1
490
TypeScript for JS Developers
pohjus
0
420
Introduction to SwiftUI (2025-04-22)
pohjus
0
260
Kotlin Coroutines
pohjus
0
540
Android HTTP Clients
pohjus
0
530
Introduction to Jetpack Compose
pohjus
2
910
Other Decks in Technology
See All in Technology
試されDATA SAPPORO [LT]Claude Codeで「ゆっくりデータ分析」
ishikawa_satoru
0
370
Claude Teamプランの選定と、できること/できないこと
rfdnxbro
1
2.2k
Hooks, Filters & Now Context: Why MCPs Are the “Hooks” of the AI Era
miriamschwab
0
150
ふりかえりがなかった職能横断チームにふりかえりを導入してみて学んだこと 〜チームのふりかえりを「みんなで未来を考える場」にするプロローグ設計〜
masahiro1214shimokawa
0
350
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
聞き手の目線で考えるプロポーザル
takefumiyoshii
0
320
Hello UUID
mimifuwacc
0
130
TanStack Start エコシステムの現在地 / TanStack Start Ecosystem 2026
iktakahiro
1
380
Proxmox超入門
devops_vtj
0
180
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
23k
組織的なAI活用を阻む 最大のハードルは コンテキストデザインだった
ixbox
6
1.8k
ふりかえりを 「あそび」にしたら、 学習が勝手に進んだ / Playful Retros Drive Learning
katoaz
0
460
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
106
240k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
What's in a price? How to price your products and services
michaelherold
247
13k
Automating Front-end Workflow
addyosmani
1370
200k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
210
The Cult of Friendly URLs
andyhume
79
6.8k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
240
Navigating Weather and Climate Data
rabernat
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()); } }