Ola Galera,
to precisando de ajuda…negocio é o seguinte:
tenho esse codigo ai,mas onde marquei com asterisco quero fazer uma modificacao.Quero que o susario digite o caminho do arquivo e ele fique armazenado naquela posicao…que alteracoes preciso fazer??
[code]
import java.io.;
import java.util.;
public class array4 {
BufferedReader inReader;//hdr
PrintWriter outWriter;//hdr
String line;//hdr
private String[] args;
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 T[] = new byte[200];
byte vetortext[] = new byte[200];
int bytelidos = 0;
String t;
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
try {
File in = new File(“G:/tiago/Java/JavaProjects/array4/classes/Nutz_Esri.flt”); ******
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();
}
}
}[/code]