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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
//Ceci importe la classe Scanner du package java.util
import java.util.Scanner;
//Ceci importe toutes les classes du package java.util
import java.util.*;
import java.io.*;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JPanel;
public class test {
public static void main(String[] args){
JFrame fenetre = new JFrame();
fenetre.setTitle("Programme Surveillance Parc Informatique");
fenetre.setSize(400, 1000);
fenetre.setLocationRelativeTo(null);
//Termine le processus lorsqu'on clique sur la croix rouge
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Et enfin, la rendre visible
fenetre.setVisible(true);
//create file object
File file = new File("\\\\NAS-83-C2-91\\media\\Plateforme_COL\\plateformes\\CENTRAL-PC\\log_annexe.txt");
File file2 = new File("\\\\NAS-83-C2-91\\media\\Plateforme_COL\\plateformes\\ANNEXE_2-PC\\log_annexe.txt");
BufferedInputStream bin = null;
try
{
//create FileInputStream object
FileInputStream fin = new FileInputStream(file);
FileInputStream fin2 = new FileInputStream(file2);
//create object of BufferedInputStream
bin = new BufferedInputStream(fin);
bin = new BufferedInputStream(fin2);
//create a byte array
byte[] contents = new byte[1024];
byte[] contents2 = new byte[1024];
int bytesRead=0;
String strFileContents;
String strFileContents2;
while( (bytesRead = bin.read(contents)) != -1){
strFileContents = new String(contents, 0, bytesRead);
strFileContents2 = new String(contents, 0, bytesRead);
System.out.print(strFileContents);
System.out.print(strFileContents2);
}
}
catch(FileNotFoundException e)
{
System.out.println("File not found" + e);
}
catch(IOException ioe)
{
System.out.println("Exception while reading the file "
+ ioe);
}
finally
{
//close the BufferedInputStream using close method
try{
if(bin != null)
bin.close();
}catch(IOException ioe)
{
System.out.println("Error while closing the stream :"
+ ioe);
}
}
}
} |
Partager