Ola galera,
alguem pode me ajudar a resolver o erro q esta aparecendo ao rodar esse programa:
import java.io.;
import java.util.;
class array4 {
public static void main(String[] args) {
BufferedReader inReader = null;//hdr
PrintWriter outWriter = null;//hdr
String line;//hdr
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
String line = null,lineTokens;//hdr
BufferedReader inReader = null;//hdr
PrintWriter outWriter = null;//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
//.hdr file
try {
inReader = new BufferedReader(new FileReader(
"G:/tiago/Java/JavaProjects/array4/classes/Nutz_Esri.hdr"));
}
catch (FileNotFoundException e) {
System.out.println("Achtung,InFile not found !!!");
System.exit(1);
}
FileReader H_infile = null;
try {
FileReader H_Infile = new FileReader(
"G:/tiago/Java/JavaProjects/array4/classes/Nutz_Esri.hdr ");
}
catch (FileNotFoundException ex) {
}
BufferedReader H_datain = new BufferedReader(H_infile);
try {
line = H_datain.readLine();
}
catch (IOException ex1) {
}
StringTokenizer Tokens2 = new StringTokenizer(line," ");
try {
outWriter = new PrintWriter(new FileWriter(
"G:/tiago/Java/JavaProjects/array4/classes/HCopy.txt"));
}
catch (FileNotFoundException e) {
System.out.println("Achtung,Could not open Exit File !!!");
System.exit(1);
}
catch (IOException e) {
System.err.println(e.getMessage());
System.exit(1);
}
try {
lineTokens = Tokens2.nextToken();//colums
H_ncols = Integer.valueOf(lineTokens).intValue();
System.out.println("N_cols =" + H_ncols);
lineTokens = Tokens2.nextToken();//rows
H_nrows = Integer.valueOf(lineTokens).intValue();
System.out.println("N_rows =" + H_nrows);
lineTokens = Tokens2.nextToken();//XCorner
H_XCorner = Double.valueOf(lineTokens).doubleValue();
System.out.println("N_XCorner =" + H_XCorner);
lineTokens = Tokens2.nextToken();//YCorner
H_YCorner = Double.valueOf(lineTokens).doubleValue();
System.out.println("N_YCorner =" + H_YCorner);
lineTokens = Tokens2.nextToken();//CellSize
H_CellSize = Integer.valueOf(lineTokens).intValue();
System.out.println("CellSize =" + H_CellSize);
H_Byteorder = lineTokens;//Byteorder
System.out.println("Byteoder =" + H_Byteorder);
lineTokens = Tokens2.nextToken();//NodataValue
H_Nodatavalue = Double.valueOf(lineTokens).doubleValue();
System.out.println("Nodatavalue =" + H_Nodatavalue);
inReader.close();
outWriter.close();
}
catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
Se alguem puder me ajudar…
Preciso pegar um arquivo que contem os seguintes dados:
ncols 254
nrows 179
xllcorner 3372500
yllcorner 5359500
cellsize 1000
byteorder MSBFIRST
nodata_value -9999
preciso abrir o arquivo,ler,e o reescreve-lo em outro novo arquivo,mas ta dando pau…e nao ta rodando.
Obrigado


