File Path Delimiters
Overview
Because screen-scraper internally uses Java it is important that file paths follow the requirements of Java. That is that file paths follow the Unix/Linux structure (e.g., /usr/local/file.txt). If you are working on a machine that follows these conventions then it will not look any different to you; however, if you are working on a Windows machine this is an important difference to keep in mind.
Windows uses the backslash (\) as a file delimiter but Java uses it as an escape character. That means that on a Windows machine you need to pay closer attention to file paths as they will look a little different.
Windows file paths should use either a forward slash (/) or two backslashes (\\) to delimit file paths.
Windows Example
try{<br />
// Set file path<br />
outputFilePath = "C:/tmp/output/output.txt";<br />
// "C:\\tmp\\output\\output.txt"; would also work<br />
<br />
// Create a FileWriter objec<br />
FileWriter out = new FileWriter(outputFilePath);<br />
<br />
// Write in the file<br />
out.write("I love scripting in Screen-Scraper");<br />
<br />
//Closes the stream.<br />
<br />
out.close();<br />
<br />
}<br />
catch(Exception e)<br />
{<br />
// Log error if exists<br />
session.log(e.getMessage());<br />
}
// Set file path<br />
outputFilePath = "C:/tmp/output/output.txt";<br />
// "C:\\tmp\\output\\output.txt"; would also work<br />
<br />
// Create a FileWriter objec<br />
FileWriter out = new FileWriter(outputFilePath);<br />
<br />
// Write in the file<br />
out.write("I love scripting in Screen-Scraper");<br />
<br />
//Closes the stream.<br />
<br />
out.close();<br />
<br />
}<br />
catch(Exception e)<br />
{<br />
// Log error if exists<br />
session.log(e.getMessage());<br />
}
scraper on 07/16/2010 at 5:23 pm
- Printer-friendly version
- Login or register to post comments