简体   繁体   English

从Java服务器下载字体文件

[英]Download font file from server in java

I am new in java and would like to download some font file from serve through ftpclient..I have successfully downloaded some fonts of format .ttf while am facing problem in downloading .woff format files. 我是Java新手,想通过ftpclient从服务下载一些字体文件。我已经成功下载了.ttf格式的某些字体,而在下载.woff格式文件.woff问题。 Can anyone help me with this? 谁能帮我这个? I have included part of my code. 我已经包含了部分代码。 No exception is shown but while calling ftpclient.retrievefile() i get false as reply. 没有显示异常,但是在调用ftpclient.retrievefile()我得到了false作为答复。 The path is correct and server have the file i am about to download 路径正确,服务器上有我要下载的文件

File downloadFile1 = new File(FileSavedPath);//creating new file
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(downloadFile1));
String path = "/dv2/" + fctypeId + "/" + remotefilename;
boolean success = false;
try 
{
    success = ftpClient.retrieveFile(path, outputStream);

}
catch(CopyStreamException cp)
{
    out.println(cp.getMessage());
}
catch(FTPConnectionClosedException error) 
{
    out.println(error.getMessage());
}
catch (IOException ex) {
    out.println(ex.getMessage());
}
outputStream.close();

Now i see that some latin fonts gets downloaded but while calling .retrievefil,it doesnot return TRUE. 现在,我看到一些拉丁字体已下载,但是在调用.retrievefil时,它不返回TRUE。

I can't see any obvious bugs in the code, and if it works for the .ttf files then I can only imagine it's some subtle typo in the path. 我看不到代码中任何明显的错误,如果它适用于.ttf文件,那么我只能想象这是路径中的一些细微错字。

Can you try printing out the path that you are retrieving so you can double-check it? 您可以尝试打印出要检索的路径,以便再次检查吗?

...
try
{
    System.out.println("Retrieving: '" + path + "'");
    success = ftpClient.retrieveFile(path, outputStream);
}
...

Also, I wonder whether the ftpClient is in some kind of pending state due to previous actions? 另外,我想知道ftpClient是否由于先前的操作而处于某种挂起状态? Can you isolate this retrieval so that nothing else but connection to the FTP site is performed before it? 您能否隔离此检索,以便在此之前仅执行与FTP站点的连接?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM