Galera fiz o seguinte codigo:
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) {
// TODO code application logic here
try {
BufferedReader in = new BufferedReader(new FileReader("teste.txt"));
String str = "";
String te = "";
int i;
while (in.ready()) {
str = in.readLine();
process(str);
}
in.close();
} catch (IOException e) {
System.out.println("Nao achou");
}
}
private static void process(String str) {
// TODO Auto-generated method stub
char A1,A2;
StringBuffer str1 = new StringBuffer();
int i;
i = str.length();
A1 = str.charAt(i-1);
A2 = str.charAt(i-2);
str1 = str1.append(A2);
str1 = str1.append(A1);
StringBuffer o = new StringBuffer();
o.append(str1);
System.out.println(o);
}
}
o arquivo teste em um arquivo texto q contem o seguinte
teste
carlos
henrique
qnd executado o codigo ele retorna as 2 ultimos caracteres entao sendo assin ele retorna
te
os
ue
so q eu quero q sai da seguinte forma : teosue
tem como?
vlw