java:byte_streams_to_data
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:byte_streams_to_data [2021/04/04 16:42] – [Μετασχηματισμός των ροών δυαδικών δεδομένων σε βασικούς τύπους δεδομένων] gthanos | java:byte_streams_to_data [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 115: | Line 115: | ||
| <code java DataInputOutputStreamTest.java> | <code java DataInputOutputStreamTest.java> | ||
| - | |||
| import java.nio.*; | import java.nio.*; | ||
| import java.io.*; | import java.io.*; | ||
| Line 135: | Line 134: | ||
| | | ||
| public static void main(String []args ) { | public static void main(String []args ) { | ||
| - | File file = new File("my.bin" | + | File file = new File("file.bin" |
| write(file); | write(file); | ||
| read(file); | read(file); | ||
| Line 143: | Line 142: | ||
| int a = -159954; | int a = -159954; | ||
| double b = 125.128953; | double b = 125.128953; | ||
| - | char c = 'Ξ'; | + | char c = 'Θ'; |
| String str = " | String str = " | ||
| | | ||
| Line 164: | Line 163: | ||
| double b = in.readDouble(); | double b = in.readDouble(); | ||
| char c = in.readChar(); | char c = in.readChar(); | ||
| - | byte [] str = new byte[18]; | + | byte [] bytes = new byte[512]; |
| - | in.read(str); | + | |
| - | | + | |
| - | System.out.println(new String(str, java.nio.charset.StandardCharsets.UTF_16)); | + | |
| System.out.println(a); | System.out.println(a); | ||
| System.out.println(b); | System.out.println(b); | ||
| - | System.out.println(c); | + | System.out.println("'" |
| - | | + | System.out.println(new String(bytes, |
| } | } | ||
| catch(IOException ex) { | catch(IOException ex) { | ||
| Line 179: | Line 177: | ||
| } | } | ||
| } | } | ||
| - | |||
| </ | </ | ||
java/byte_streams_to_data.1617554549.txt.gz · Last modified: 2021/04/04 15:42 (external edit)
