00001 package RommelPakket;
00002
00003 import java.io.DataInputStream;
00004 import java.io.DataOutputStream;
00005 import java.io.File;
00006 import java.io.FileInputStream;
00007 import java.io.FileNotFoundException;
00008 import java.io.FileOutputStream;
00009 import java.io.IOException;
00010
00011 public class WegschrijvenNaarFileEnTerug {
00012
00013 public WegschrijvenNaarFileEnTerug() {
00014 super();
00015
00016 }
00017
00018
00019 public void wegSchrijven(){
00020 String sep=File.separator;
00021 FileOutputStream fileOutputStream=null;
00022 File file= new File("C:"+sep+"binair.txt");
00023 try{
00024 fileOutputStream=new FileOutputStream(file);
00025 }catch(FileNotFoundException fileNotFoundException){
00026 fileNotFoundException.printStackTrace(System.out);
00027 }
00028 DataOutputStream dataOutputStream =new DataOutputStream(fileOutputStream);
00029 try{
00030 int getal=129;
00031 dataOutputStream.writeByte(getal);
00032 Debug.print("getal "+getal +" weggeschreven");
00033 dataOutputStream.flush();
00034 dataOutputStream.close();
00035 }catch(IOException exception){
00036 exception.printStackTrace(System.out);
00037 }
00038
00039
00040 FileInputStream fileInputStream=null;
00041 try{
00042 fileInputStream=new FileInputStream(file);
00043 }catch(FileNotFoundException fileNotFoundException){
00044 fileNotFoundException.printStackTrace(System.out);
00045 }
00046 DataInputStream dataInputStream =new DataInputStream(fileInputStream);
00047 try{
00048 int getal = dataInputStream.readByte();
00049 Debug.print("getal "+getal+ " gelezen");
00050 }catch(IOException exception){
00051 exception.printStackTrace(System.out);
00052 }
00053
00054
00055
00056 }
00057
00058 public static void main (String args[]){
00059 WegschrijvenNaarFileEnTerug fileEnTerug=new WegschrijvenNaarFileEnTerug();
00060 fileEnTerug.wegSchrijven();
00061
00062 }
00063
00064 }