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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Jussi Pohjolainen
April 26, 2020
Technology
250
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
190
Modern software development and fundamentals of AI
pohjus
0
170
C / C++ - language
pohjus
1
550
TypeScript for JS Developers
pohjus
0
450
Introduction to SwiftUI (2025-04-22)
pohjus
0
290
Kotlin Coroutines
pohjus
0
570
Android HTTP Clients
pohjus
0
550
Introduction to Jetpack Compose
pohjus
2
980
Other Decks in Technology
See All in Technology
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
330
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
160
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
230
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
550
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
110
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
110
こんなアーキテクチャ図は嫌だ BEYOND THE TIME: 半年後の自分へ贈る15のメッセージ / 15 of Anti-pattern in AWS Architecture Diagrams
naospon
3
270
Benchmarking Vector Databases: pgvector vs. LanceDB
tsho
0
150
振り返りこそエンジニアの本領
negima
0
340
AIで実装は速くなった。なのにプロダクトは速くならない。職能の壁を越えて価値のフローを設計する
nwiizo
7
7.4k
多摩川(.dev)ランニング入門 / Tamagawa.dev#3
fujiwara3
3
400
Deploying a Full-Stack Bun-Native Framework on Cloudflare Workers
7nohe
0
110
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
410
The Pragmatic Product Professional
lauravandoore
37
7.4k
Making the Leap to Tech Lead
cromwellryan
135
10k
Six Lessons from altMBA
skipperchong
29
4.5k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
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()); } }