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
220
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.9k
Sustainability in Web Development - How to Optimize React Apps?
pohjus
0
160
Modern software development and fundamentals of AI
pohjus
0
150
C / C++ - language
pohjus
1
490
TypeScript for JS Developers
pohjus
0
420
Introduction to SwiftUI (2025-04-22)
pohjus
0
250
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
俺の/私の最強アーキテクチャ決定戦開催 ― チームで新しいアーキテクチャに適合していくために / 20260322 Naoki Takahashi
shift_evolve
PRO
1
440
Phase05_ClaudeCode入門
overflowinc
0
2.1k
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
230
Phase02_AI座学_応用
overflowinc
0
2.8k
Amazon Qはアマコネで頑張っています〜 Amazon Q in Connectについて〜
yama3133
1
110
DMBOKを使ってレバレジーズのデータマネジメントを評価した
leveragestech
0
260
「捨てる」を設計する
kubell_hr
0
240
BFCacheを活用して無限スクロールのUX を改善した話
apple_yagi
0
120
How to install a gem
indirect
0
1.4k
Phase06_ClaudeCode実践
overflowinc
0
2k
20260320_JaSST26_Tokyo_登壇資料.pdf
mura_shin
0
120
CloudFrontのHost Header転送設定でパケットの中身はどう変わるのか?
nagisa53
1
170
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
690
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Test your architecture with Archunit
thirion
1
2.2k
The Curious Case for Waylosing
cassininazir
0
280
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
300
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
300
Designing Powerful Visuals for Engaging Learning
tmiket
0
290
The World Runs on Bad Software
bkeepers
PRO
72
12k
Building Applications with DynamoDB
mza
96
7k
We Are The Robots
honzajavorek
0
200
Tell your own story through comics
letsgokoyo
1
870
Producing Creativity
orderedlist
PRO
348
40k
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()); } }