Browse Source

Adding cat

main
Jesus 2 years ago
parent
commit
baa8fe95af
4 changed files with 31 additions and 1 deletions
  1. +8
    -0
      README.md
  2. BIN
      bin/com/jesuspinar/main/Main.class
  3. +22
    -1
      src/com/jesuspinar/main/Main.java
  4. +1
    -0
      src/com/jesuspinar/main/test.txt

+ 8
- 0
README.md View File

@ -0,0 +1,8 @@
# Cat cmd
- Pasar ruta absoluta del archivo
Ejemplo : /Users/jesuspl/SpringTool_workspace/miCat/src/com/jesuspinar/main/test.txt
```
hola mundo
```

BIN
bin/com/jesuspinar/main/Main.class View File


+ 22
- 1
src/com/jesuspinar/main/Main.java View File

@ -1,9 +1,30 @@
package com.jesuspinar.main;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
readTxt("/Users/jesuspl/SpringTool_workspace/miCat/src/com/jesuspinar/main/test.txt");
}
public static String readTxt(String path) {
StringBuilder sb = new StringBuilder();
try (FileReader fileReader = new FileReader(new File(path));
BufferedReader bf = new BufferedReader(fileReader)) {
String ln;
while ((ln = bf.readLine()) != null) {
sb.append(ln);
System.out.printf("%s", ln);
}
}catch (IOException ioe){
System.err.println("Archivo no valido");
}
return sb.toString();
}
}

+ 1
- 0
src/com/jesuspinar/main/test.txt View File

@ -0,0 +1 @@
Hola mundo

Loading…
Cancel
Save