-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjystring.py
More file actions
32 lines (22 loc) · 712 Bytes
/
jystring.py
File metadata and controls
32 lines (22 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from java.lang import StringBuffer, System
sb = StringBuffer(100) # Preallocate StringBuffer size for performance.
sb.append('The platform is: ')
sb.append(sys.platform) # Python property
sb.append(' time for an omelette.')
sb.append('\n') # Newline
sb.append('Home directory: ')
sb.append( System.getProperty('user.home') )
sb.append('\n') # Newline
sb.append('Some numbers: ')
sb.append(44.1)
sb.append(', ')
sb.append(42)
sb.append(' ')
# Try appending a tuple.
tup=( 'Red', 'Green', 'Blue', 255, 204, 127 )
sb.append(tup)
print(sb.toString())
# Treat java.util.Properties as Python dictionary.
props = System.getProperties()
print('User home directory:', props['user.home'])