Skip to content

Instantly share code, notes, and snippets.

@JuanjoSalvador
Created June 18, 2015 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JuanjoSalvador/8bed02945406fa42b0bd to your computer and use it in GitHub Desktop.
Save JuanjoSalvador/8bed02945406fa42b0bd to your computer and use it in GitHub Desktop.
public class main {
public static void cambiaLetras() {
try {
FileReader fr = new FileReader("texto.txt");
BufferedReader br = new BufferedReader(fr);
String str = null;
while ((str = br.readLine()) != null) {
for (int i = 0; i < str.length(); i++) {
int charac = str.charAt(i);
if (charac != 32 && charac < 132) {
int characMayus = charac + 32;
System.out.print((char) characMayus);
}
if (charac != 32 && charac > 132) {
int characMinus = charac - 32;
System.out.print((char) characMinus);
}
if (charac == 32) {
System.out.print((char) 32);
}
if (charac == 10) {
System.out.println("\n");
}
}
}
} catch (IOException ex) {
System.out.println("No se encontró el archivo");
}
}
public static void main(String[] args) {
cambiaLetras();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment