• Keine Ergebnisse gefunden

Read / Write

N/A
N/A
Protected

Academic year: 2021

Aktie "Read / Write"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

1

Read / Write

import java.io.*;

private static void test1() { // Stream

try {

FileOutputStream fout = new FileOutputStream("1.txt");

String s = "1. Zeile";

for (char ch : s.toCharArray() ) { fout.write( (int) ch);

}

s = "2. Zeile";

for (char ch : s.toCharArray() ) { fout.write( (int) ch);

}

fout.close();

}

catch (IOException ee) {

System.err.println("IOException: " + ee);

} } // test1

(2)

2 import java.io.*;

private static void test1() { try {

FileOutputStream Fout = new FileOutputStream("1.txt");

PrintStream p = new PrintStream(Fout); // weiterleiten zu einem PrintStream p.print("1. Zeile");

int i;

p.println("Montag morgen");

p.println("123.34");

p.print("abc");

p.print("123");

i=345;

p.print(i);

double d1=123.5678;

p.println(d1);

p.println("Letzte Zeile");

p.close();

} // try

catch (IOException ee) {

System.err.println("IOException: " + ee);

} } // test1

(3)

3 import java.io.*;

public void test2() { FileInputStream fin;

InputStreamReader iin;

LineNumberReader din;

String sLine;

try {

fin = new FileInputStream("readASCII01.java");

iin = new InputStreamReader(fin);

din = new LineNumberReader(iin); // oder BufferedReader br = new BufferedReader(ir);

while ( din.ready() ) { sLine = din.readLine();

System.out.println(sLine);

} // while } // try

catch (FileNotFoundException e1) {

System.err.println("Die Datei war nicht vorhanden!");

}

catch (IOException ee) {

System.err.println("IOException: " + ee);

} } // test2

Referenzen

ÄHNLICHE DOKUMENTE

• The different instances of the body are translated relative to possibly different initial states :-). • The code behind the loop must be correct relative to the exit

Most microprocessor architecture does not require a common input port select at the card level, so generally the cornmon input port is tied to ground (the

Read Nudge Pressure Roll Read Eject Pressure Roll Read Eject Roll Drag Button Adjusting Plate Punch -Drag iButto N N Card Patter.. Read

◆ nach dem Commit können geänderte Seiten im Puffer verbleiben, ohne explizit auf dem stabilen Speicher gesichert werden. → Redo-Protokollinformationen im stabilen

Method and apparatus for automatic write current calibration in a streaming tape drive.. actual write

Read the beginning of the story?. What

[r]

diskette contains the CP/M (Control Program for Microcomputers) program, which operates the computer, and programs such as word processing, spreadsheet, etc... CARE