|
|||
|
I cant seem to use StringStream correctly. Here is what I am trying to use;
Code:
//Initialize
trace("Initializing:.....................................");
getAdditionalFile();
var stringIn = new StringStream($STREAM_IN);
var stringOut = new StringStream($STREAM_OUT);
//var basePath = getAppDir();
var basePath = "F:\\data\\synergy management consulting\\risk maturity\\01 Source\\Scripts\\questionDev\\stringDecoder\\Application";
trace("basePath = "+basePath);
trace("File.exists(basePath+\"\\in.txt\") = " + File.exists(basePath+"\\in.txt"));
stringIn.readFromFile(basePath+"\\in.txt");
trace("stringIn.getPos = " + stringIn.getPos);
trace("stringIn.eof = " + stringIn.eof);
var lineRead = stringIn.readLine();
var i = 0;
trace("stringIn.readUnicodeString() = " + stringIn.readUnicodeString());
trace("stringIn.readString() = " + stringIn.readString());
trace("stringIn.get() = " + stringIn.get());
trace("stringIn.readLine() = " + stringIn.readLine());
trace("stringIn.uncompress() = " + stringIn.uncompress());
stringOut.writeLine("questions = new Array();");
while(stringIn.eof != true){
trace("lineRead = " + lineRead);
trace("stringIn.getPos = " + stringIn.getPos);
stringOut.writeLine(lineRead);
readLine = stringIn.readLine();
i++;
}
stringOut.saveToFile(basePath+"\\out.txt");
stringOut.close();
stringIn.close();
return true;
File.exists(basePath+"\in.txt") = true stringIn.getPos = -1 stringIn.eof = false stringIn.readUnicodeString() = stringIn.readString() = stringIn.get() = -1 stringIn.readLine() = stringIn.uncompress() = and it saves an empty file. So the file exists. And it saves something. But i'm not successfully doing anything with the FileStream. I was hoping somebody could tell me what i'm doing wrong. Again, i appologize for the length of this post. Jon |
|
|||
|
The "readFromFile" method is a static method, so you will have to call it as follows
Code:
stringIn= StringStream.readFromFile(basePath+"\\in.txt"); Code:
stringIn.readFromFile(basePath+"\\in.txt"); |
|
|||
|
Thankyou very much, I think I'm nearly there.
However I'm just reading the first line over and over, how do I 'move the read head?'. Maybe a better question is 'How should I best read a .txt file, line by line?'. Thanks again Jon |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|