Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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.7k
Sustainability in Web Development - How to Optimize React Apps?
pohjus
0
130
Modern software development and fundamentals of AI
pohjus
0
130
C / C++ - language
pohjus
1
470
TypeScript for JS Developers
pohjus
0
390
Introduction to SwiftUI (2025-04-22)
pohjus
0
220
Kotlin Coroutines
pohjus
0
520
Android HTTP Clients
pohjus
0
500
Introduction to Jetpack Compose
pohjus
2
870
Other Decks in Technology
See All in Technology
プラットフォームエンジニアリングとは何であり、なぜプラットフォームエンジニアリングなのか
doublemarket
1
530
ページの可視領域を算出する方法について整理する
yamatai1212
0
160
Noを伝える技術2025: 爆速合意形成のためのNICOフレームワーク速習 #pmconf2025
aki_iinuma
2
330
.NET 10 のパフォーマンス改善
nenonaninu
2
4.5k
Kill the Vibe?Architecture in the age of AI
stoth
1
160
Introduction to Bill One Development Engineer
sansan33
PRO
0
320
オープンデータの内製化から分かったGISデータを巡る行政の課題
naokim84
2
1.3k
AIにおける自由の追求
shujisado
2
450
HIG学習用スライド
yuukiw00w
0
110
Claude Code Getting Started Guide(en)
oikon48
0
120
[続・営業向け 誰でも話せるOCI セールストーク] AWSよりOCIの優位性が分からない編(2025年11月21日開催)
oracle4engineer
PRO
1
220
Databricksによるエージェント構築
taka_aki
1
110
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.3k
Documentation Writing (for coders)
carmenintech
76
5.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
4 Signs Your Business is Dying
shpigford
186
22k
Unsuck your backbone
ammeep
671
58k
The Language of Interfaces
destraynor
162
25k
GitHub's CSS Performance
jonrohan
1032
470k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
A designer walks into a library…
pauljervisheath
210
24k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
70
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()); } }