2

Imagine a kind of CSV file you need to parse on the fly.

It works in local disk storage but not in ram:///

<cfscript>

cfhttp(
    method = "Get",
    url = "http://real-chart.finance.yahoo.com/table.csv?s=YHOO&d=4&e=2&f=2016&g=d&a=3&b=12&c=2016&ignore=.csv",
    //path = "C:\CFTemp",
    path = "ram:///",
    file = "currentCSV.csv"
);

cfdirectory(
    name="files",
    action="list",
    directory="ram:///",
    recurse="true",
    type="all"
);
writeDump(files);

myfile = FileRead("ram:///currentCSV.csv");
WriteOutput("#myfile#");


fileReader = createobject("java","java.io.FileReader");
fileReader.init("ram:///currentCSV.csv");  // -ERROR

csvReader = createObject("java","com.opencsv.CSVReader");
csvReader.init(fileReader, ",");
ArrayData = csvReader.readAll();
writeDump(ArrayData);

</cfscript>

-ERR ram:/currentCSV.csv (The filename, directory name, or volume label syntax is incorrect)

What's wrong in here?

ColdFusion 11, OpenCSV 3.7

master-lame-master
  • 3,101
  • 2
  • 30
  • 47

1 Answers1

5

VFS or "ram:///" is a CF construct that only works with ColdFusion functions. FileReader is a java class that does not know anything about VFS. AFAIK, its constructor only accepts a standard file path, ie c:/path/file.txt.

Leigh
  • 28,765
  • 10
  • 55
  • 103