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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Jussi Pohjolainen
April 26, 2020
Technology
240
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
180
Modern software development and fundamentals of AI
pohjus
0
160
C / C++ - language
pohjus
1
530
TypeScript for JS Developers
pohjus
0
440
Introduction to SwiftUI (2025-04-22)
pohjus
0
280
Kotlin Coroutines
pohjus
0
560
Android HTTP Clients
pohjus
0
540
Introduction to Jetpack Compose
pohjus
2
960
Other Decks in Technology
See All in Technology
AI工学特論: MLOps・継続的評価
asei
11
3k
脱Jenkins、インターン生が挑んだCIツールGitHubActions移行
mixi_engineers
PRO
1
260
データベース研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
680
plamo-3-translateの開発
pfn
PRO
0
170
書籍セキュアAPIについて
riiimparm
0
390
基調講演:人とAIをつなぐIoTの今と未来 ー 「フィジカル」と「デジタル」が出会うその先へ【SORACOM Discovery 2026】
soracom
PRO
0
360
AIがAPIを書く時代に、私たちは何を設計すべきか
nagix
0
160
システム監視を 「システムを監視するだけ」で 終わらせないために
seiud
0
150
AWS環境のセキュリティ不安を解消した企業事例 ~よくある課題と対策を一挙公開~
asanoharuki
0
240
「休む」重要さ
smt7174
7
1.8k
データと地図で読む 大井町の「かわるもの、かわらないもの」
yoshiyama_hana
0
650
データ組織の転換期 一足飛びしない段階的戦略
leveragestech
PRO
0
100
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The Limits of Empathy - UXLibs8
cassininazir
1
560
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
430
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
230
Documentation Writing (for coders)
carmenintech
77
5.4k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
750
Build your cross-platform service in a week with App Engine
jlugia
234
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
370
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
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()); } }