Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication21;
- import java.io.IOException;
- import java.io.RandomAccessFile;
- /**
- *
- * @author MDLejTeCole
- */
- public class JavaApplication21
- {
- public static void emerytura(String text) throws IOException
- {
- RandomAccessFile raw = null;
- String gw="";
- long wskaznik2;
- char plec;
- String imie ="";
- String nazwisko;
- int wiek;
- try
- {
- raw = new RandomAccessFile(text,"rw");
- raw.writeUTF("Mam");
- raw.writeUTF("Java");
- raw.writeChar('K');
- raw.writeInt(35);
- raw.writeUTF("Wak");
- raw.writeUTF("Paw");
- raw.writeChar('K');
- raw.writeInt(59);
- raw.writeUTF("Draw");
- raw.writeUTF("Ciach");
- raw.writeChar('M');
- raw.writeInt(59);
- raw.writeUTF("Mam");
- raw.writeUTF("Java");
- raw.writeChar('M');
- raw.writeInt(54);
- raw.writeUTF("Zaam");
- raw.writeUTF("Wa");
- raw.writeChar('K');
- raw.writeInt(38);
- //gw = raw.readLine();
- while(true)
- {
- //System.out.print("Siema");
- imie = raw.readUTF();
- nazwisko = raw.readUTF();
- plec = raw.readChar();
- wskaznik2 = raw.getFilePointer();
- wiek = raw.readInt();
- if(plec == 'K')
- {
- raw.seek(wskaznik2);
- wiek = 60 - wiek;
- }
- if(plec == 'M')
- {
- raw.seek(wskaznik2);
- wiek = 65 - wiek;
- }
- //gw = raw.readLine();
- }
- }
- catch(IOException ex)
- {
- System.out.print("bląd");
- ex.getStackTrace();
- }
- finally
- {
- if (raw != null)
- {
- raw.close();
- }
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException{
- emerytura("siemaa.txt");
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement