import java.io.;
import java.util.;
public class array4 {
BufferedReader inReader;//hdr
PrintWriter outWriter;//hdr
String line;//hdr
public array4 () //constructor
{ BufferedReader inReader = null;
PrintWriter outWriter = null;
}
public static void main(String[] args) {
array4 f = new array4();
f.readMyFile();
}
void readMyFile() {
array4 f = new array4();
DataInputStream data = null; //Variables
DataOutputStream data2 = null;
String record = null;
int recCount = 0;
int n_rows, n_cols;
int c;
double dummy;
n_rows = 179; //x
n_cols = 254; //y
double[][] points = new double[n_rows][n_cols]; //2D Array
float a; //receive datas from 2D Arry
byte text[] = new byte[200];
byte vetortext[] = new byte[200];
int bytelidos = 0;
String line = null,lineTokens;//hdr
int H_ncols;//hdr
int H_nrows;//hdr
double H_XCorner;//hdr
double H_YCorner;//hdr
int H_CellSize;//hdr
String H_Byteorder;//hdr
double H_Nodatavalue;//hdr
System.out.println(“Complete File Directory:”);//
try {
bytelidos = System.in.read(vetortext);//*
-> File in = new File(vetortext,0,bytelidos);//*
FileInputStream fis = new FileInputStream(in);
BufferedInputStream bis = new BufferedInputStream(fis);
data = new DataInputStream(bis);
for (int y = 0; y < n_cols; y++) {
for (int x = 0; x < n_rows; x++) {
try {
points[x][y] = (double) data.readFloat();
System.out.println("Input x : " + x + " ;" + " y : " + y + " ->" +
" Value : " + (float)points[x][y]);
}
catch (EOFException e) {
// catch EOF occuring while reading
System.out.println("ACHTUNG,got an EOFException error! " +
e.getMessage());
}
}
}
}
catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("ACHTUNG, got an IOException error! " + e.getMessage());
}
finally {
// if the file opened okay, make sure we close it
if (data != null) {
try {
data.close();
}
catch
(IOException ioe) {
}
}
}
File out = new File("G:/tiago/Java/JavaProjects/array4/classes/copy2.bin"); //copy-out
FileOutputStream fos = null;
try {
fos = new FileOutputStream(out);
}
catch (FileNotFoundException ex) {
}
BufferedOutputStream bos = new BufferedOutputStream(fos);
data2 = new DataOutputStream(bos);
try {
FileWriter saida = new FileWriter(out);
}
catch (IOException ex1) {
System.out.println("Achtung,problems with creating the output file " + ex1.getMessage());
}
for (int y = 0; y < n_cols; y++) {
for (int x = 0; x < n_rows; x++) {
try {
a = (float)points[x][y];
System.out.println("Output x : " + x + " ;" + " y : " + y + " ->" +
" Value : " + a);
data2.writeFloat(a);
}
catch (IOException ioe) {
System.out.println("Achtung,problems with writing data" + ioe.getMessage());
}
}
}try{
data2.close();
}catch(IOException e) {
e.getMessage();
}
}
}
Onde indiquei com uma seta,como faco por exemplo,peco pro usuario digitar onde esta o arquivo que ele quer abrir,salvar essa string numa variavel e coloca-la naquela linha onde esta a seta,ou sei la…como faco isso??