Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. package Clases;
  2.  
  3. import java.io.*;
  4.  
  5.  
  6. public class GestionCheats {
  7. FileInputStream entrada;
  8. FileOutputStream salida;
  9. File archivo;
  10.  
  11. public GestionCheats(){
  12.  
  13. }
  14.  
  15. /*Abrir un archivo de texto*/
  16. public String AbrirATexto(File archivo){
  17. String contenido="";
  18. try {
  19. entrada = new FileInputStream(archivo);
  20. int ascci;
  21. while((ascci = entrada.read())!= -1){
  22. char carcater = (char)ascci;
  23. contenido += carcater;
  24. }
  25. } catch (Exception e) {
  26. }
  27. return contenido;
  28. }
  29.  
  30. /*Guardar archivo de texto*/
  31. public String GuardarATexto(File archivo, String contenido){
  32. String respuesta=null;
  33. try {
  34. salida = new FileOutputStream(archivo);
  35. byte[] bytesTxt = contenido.getBytes();
  36. salida.write(bytesTxt);
  37. respuesta = "Se guardo con exito el archivo";
  38. } catch (Exception e) {
  39. }
  40. return respuesta;
  41. }
  42.  
  43.  
  44.  
  45. public String GuardarAImagen(File archivo, byte[] bytesImg){
  46. String respuesta=null;
  47. try {
  48. salida = new FileOutputStream(archivo);
  49.  
  50. } catch (Exception e) {
  51. }
  52. return respuesta;
  53. }
  54. }
  55.  
  56. private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
  57. if(seleccionado.showDialog(null, "ABRIR ARCHIVO") == JFileChooser.APPROVE_OPTION){
  58. archivo = seleccionado.getSelectedFile();
  59. if(archivo.canRead()){
  60. if(archivo.getName().endsWith("ps4codedbs")){
  61.  
  62. String contenido = gestion.AbrirATexto(archivo);
  63. jTextArea1.setText(contenido);
  64.  
  65.  
  66.  
  67. String tituloarchivo=seleccionado.getSelectedFile().getName();
  68. txttitle.setText(tituloarchivo);
  69.  
  70.  
  71.  
  72.  
  73. try
  74. {
  75. FileReader fr = new FileReader(archivo);
  76. BufferedReader br = new BufferedReader(fr);
  77. ArrayList<String> records = new ArrayList<String>();
  78.  
  79. String line = null;
  80.  
  81.  
  82.  
  83. while((line = br.readLine()) != null)
  84.  
  85. {
  86. records.add(line);
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. for(int i = 0; i < records.size(); i++)
  94. {
  95. String[] array = records.get(1).split(";");
  96. String[] array1 = records.get(0).split(";");
  97.  
  98. txtcode.setText(array1[1].trim());
  99. txttitulo.setText(array[1].trim());
  100.  
  101.  
  102.  
  103.  
  104. }
  105. }
  106. catch (IOException ioe)
  107. {
  108. System.out.println("algo no va bien...");//temporary
  109. }
  110.  
  111.  
  112.  
  113.  
  114. //
  115. }else{
  116. JOptionPane.showMessageDialog(null, "Por favor seleccione un archivo .ps4codedbs");
  117. }
  118.  
  119. }
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement