Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. import java.io.FileReader;
  2. import java.io.IOException;
  3. import java.io.BufferedReader;
  4.  
  5. public class Compara
  6. {
  7. public static void main(String[] args) throws IOException
  8. {
  9. try
  10. {
  11. BufferedReader lee1 =new BufferedReader(new FileReader("original.txt"));
  12. BufferedReader lee2 =new BufferedReader(new FileReader("original.txt"));
  13.  
  14. String linea1="", linea2 = "";
  15. System.out.println("Comparando Archivos...");
  16. int cont1=0, cont2=0;
  17.  
  18. while(linea1!=null || linea2!=null)
  19. {
  20. linea1=lee1.readLine();
  21. linea2=lee2.readLine();
  22. if(linea1!=null){
  23. cont1++;
  24. }
  25. if(linea2!=null){
  26. cont2++;
  27. }
  28. };
  29. System.out.println("Fin de comparacion de los archivos...n");
  30. System.out.println("El primer archivo tiene "+cont1+" Lineas");
  31. System.out.println("El segundo archivo tiene "+cont2+" Lineas");
  32. if(cont1 == cont2){
  33. System.out.println("Los archivos comparados son iguales");
  34. }
  35. else{
  36. System.out.println("Los archivos comparados son diferentes");
  37. }
  38. lee1.close();
  39. lee2.close();
  40. }
  41. finally
  42. {
  43. System.out.println("fin...");
  44. }
  45. }
  46. }
  47.  
  48. import java.io.*; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.extractor.WordExtractor; public class ReadDocFile { public static void main(String[] args) { File file = null; WordExtractor extractor = null; try { file = new File("c:\New.doc"); FileInputStream fis = new FileInputStream(file.getAbsolutePath()); HWPFDocument document = new HWPFDocument(fis); extractor = new WordExtractor(document); String[] fileData = extractor.getParagraphText(); for (int i = 0; i < fileData.length; i++) { if (fileData[i] != null) System.out.println(fileData[i]); } } catch (Exception exep) { exep.printStackTrace(); } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement