本文整理汇总了Java中water.fvec.Frame.toCSV方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.toCSV方法的具体用法?Java Frame.toCSV怎么用?Java Frame.toCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类water.fvec.Frame
的用法示例。
在下文中一共展示了Frame.toCSV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetch
import water.fvec.Frame; //导入方法依赖的package包/类
@SuppressWarnings("unused") // called through reflection by RequestServer
public DownloadDataV3 fetch(int version, DownloadDataV3 server) {
if (DKV.get(server.frame_id.key()) == null) throw new H2OKeyNotFoundArgumentException("key", server.frame_id.key());
Frame value = server.frame_id.key().get();
InputStream is = value.toCSV(true, server.hex_string);
java.util.Scanner scanner = new java.util.Scanner(is).useDelimiter("\\A");
server.csv = (scanner.hasNext() ? scanner.next() : "");
// Clean up Key name back to something resembling a file system name. Hope
// the user's browser actually asks for what to do with the suggested
// filename. Without this code, my FireFox would claim something silly
// like "no helper app installed", then fail the download.
String s = server.frame_id.toString();
int x = s.length()-1;
boolean dot=false;
for( ; x >= 0; x-- )
if( !Character.isLetterOrDigit(s.charAt(x)) && s.charAt(x)!='_' )
if( s.charAt(x)=='.' && !dot ) dot=true;
else break;
String suggested_fname = s.substring(x+1).replace(".hex", ".csv");
if( !suggested_fname.endsWith(".csv") )
suggested_fname = suggested_fname+".csv";
server.filename = suggested_fname;
return server;
}
示例2: doGet
import water.fvec.Frame; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
String uri = getDecodedUri(request);
try {
boolean use_hex = false;
String f_name = request.getParameter("frame_id");
String hex_string = request.getParameter("hex_string");
if (f_name == null) {
throw new RuntimeException("Cannot find value for parameter \'frame_id\'");
}
if (hex_string != null && hex_string.toLowerCase().equals("true")) {
use_hex = true;
}
Frame dataset = DKV.getGet(f_name);
// TODO: Find a way to determing the hex_string parameter. It should not always be false
InputStream is = dataset.toCSV(true, use_hex);
response.setContentType("application/octet-stream");
// Clean up the file name
int x = f_name.length()-1;
boolean dot=false;
for( ; x >= 0; x-- )
if( !Character.isLetterOrDigit(f_name.charAt(x)) && f_name.charAt(x)!='_' )
if( f_name.charAt(x)=='.' && !dot ) dot=true;
else break;
String suggested_fname = f_name.substring(x+1).replace(".hex", ".csv");
if( !suggested_fname.endsWith(".csv") )
suggested_fname = suggested_fname+".csv";
f_name = suggested_fname;
response.addHeader("Content-Disposition", "attachment; filename=" + f_name);
setResponseStatus(response, HttpServletResponse.SC_OK);
OutputStream os = response.getOutputStream();
water.util.FileUtils.copyStream(is, os, 2048);
}
catch (Exception e) {
sendErrorResponse(response, e, uri);
}
finally {
logRequest("GET", request, response);
}
}