pissikePJ 4 de jan. de 2005
serah q isso rola?
try {
arquivo = new RandomAccessFile ( new File ( "arquivo.txt" ), "r" );
System . out . println ( arquivo . readChar ());
} catch ( IOException e ) {
System . out . println ( "Erro ao ler arquivo" );
} catch ( FileNotFoundException e ) {
System . out . println ( "Arquivo Inexiste" );
}
lacerdaPJ 5 de jan. de 2005
tentei isto so que esta aparecendo uns caracteres estranhos
import java.io.* ;
public class MyFileInput & # 123 ;
public static void main & # 40 ; String & # 91 ; & # 93 ; args & # 41 ; & # 123 ;
try & # 123 ;
FileInputStream f = new FileInputStream & # 40 ; "/home/gustavo/arquivoteste.txt" & # 41 ;;
DataInputStream d = new DataInputStream & # 40 ; f & # 41 ;;
while & # 40 ; true & # 41 ;
& # 123 ;
char c = d . readChar & # 40 ; & # 41 ;;
System . out . println & # 40 ; c & # 41 ;;
& # 125 ;
& # 125 ; catch & # 40 ; IOException e & # 41 ; & # 123 ;
System . out . print & # 40 ; e . getMessage & # 40 ; & # 41 ; & # 41 ;;
& # 125 ;
& # 125 ;
& # 125 ;
lacerdaPJ 5 de jan. de 2005
como converto char para string ?
lacerdaPJ 5 de jan. de 2005
estou utilizando o codigo abaixo so que os caracteres lidos nao sao os que estao no arquivo algem tem ideia do porque?
import java.io.* ;
//import java.lang.*;
//import java.nio.CharBuffer;
public class MyFileInput & # 123 ;
public static void main & # 40 ; String & # 91 ; & # 93 ; args & # 41 ; & # 123 ;
try & # 123 ;
FileInputStream f = new FileInputStream & # 40 ; "/home/gustavo/arquivoteste.txt" & # 41 ;;
DataInputStream d = new DataInputStream & # 40 ; f & # 41 ;;
while & # 40 ; true & # 41 ;
& # 123 ;
char c = d . readChar & # 40 ; & # 41 ;;
System . out . println & # 40 ; c & # 41 ;;
& # 125 ;
& # 125 ; catch & # 40 ; IOException e & # 41 ; & # 123 ;
System . out . print & # 40 ; e . getMessage & # 40 ; & # 41 ; & # 41 ;;
& # 125 ;
& # 125 ;
& # 125 ;
lacerdaPJ 7 de jan. de 2005
troquei readChar por readBytes e funcionou