在Java中,我想转换它:
https%3A%2F%2Fmywebsite%2Fdocs%2Fenglish%2Fsite%2Fmybook.do%3Frequest_type
Run Code Online (Sandbox Code Playgroud)
对此:
https://mywebsite/docs/english/site/mybook.do&request_type
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止:
class StringUTF
{
public static void main(String[] args)
{
try{
String url =
"https%3A%2F%2Fmywebsite%2Fdocs%2Fenglish%2Fsite%2Fmybook.do" +
"%3Frequest_type%3D%26type%3Dprivate";
System.out.println(url+"Hello World!------->" +
new String(url.getBytes("UTF-8"),"ASCII"));
}
catch(Exception E){
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它不能正常工作.这些%3A和%2F格式被称为什么以及如何转换它们?
我对blob URL有很多问题.
我src在YouTube上搜索视频标签,我发现该视频src如下:
src="blob:https://crap.crap"
Run Code Online (Sandbox Code Playgroud)
我打开了src视频中的blob URL,它给出了一个错误,我无法打开,但正在处理src标签.这怎么可能?
要求:
我允许用户通过拖放和其他方法将图像加载到页面中.删除图像时,我正在使用URL.createObjectURL转换为对象URL来显示图像.我没有撤销网址,因为我重复使用它.
所以,当谈到时间来创建一个FormData对象,所以我可以让他们上传的形式,在它的形象之一,是有一些方法,然后我可以扭转这一目标URL回一个Blob或File因此我可以将其添加到FormData宾语?
我的页面生成如下URL:"blob:http%3A//localhost%3A8383/568233a1-8b13-48b3-84d5-cca045ae384f"如何将其转换为普通地址?
我使用它作为一个<img>的src属性.
在Android Lollipop Web视图中,我想让用户下载生成的txt文件:
// Store some text in a data URL.
var dataUrl = (window.URL || window.webkitURL).createObjectURL(
new Blob(["Hello world. :)"]));
// Create a link that lets the user download the text file as hello.txt.
var downloadLink = document.createElement('a');
downloadLink.setAttribute('href', dataUrl);
downloadLink.innerHTML = 'Click to download.';
// Working with David on this. I did the same thing.
// Fyi, setting the 'download' attribute just makes hitting the link
// nop, ie. do nothing at all in the web view, so …Run Code Online (Sandbox Code Playgroud) 给定base64输入,我如何将其转换为Android中的PDF文件?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
setContentView(R.layout.activity_main);
// Get the PDF file to encode it into Base64
File file = new File("/mnt/sdcard/download/Base64.pdf");
try {
// Files is from Guava library
Files.toByteArray(file);
// Encoded into Base64
byte[] temp = Base64.encode(Files.toByteArray(file), Base64.DEFAULT);
// For testing purposes, wrote the encoded string to file
writeToFile(Base64.encodeToString(temp, Base64.DEFAULT).toString());
} catch (IOException e) {
Log.d(tag, "File.toByteArray() error");
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我能够使用http://www.webutils.pl/index.php?idx=base64来测试PDF文件是否正确编码.但我希望能够自己将base64解码为PDF.我该怎么办?
编辑1
按照Saneesh CS的建议尝试以下代码
@Override
protected void onCreate(Bundle savedInstanceState) { …Run Code Online (Sandbox Code Playgroud) 我有一个HTML网页,其中有一个按钮,当用户点击时会触发POST请求.请求完成后,将触发以下代码:
window.open(fileUrl);
Run Code Online (Sandbox Code Playgroud)
浏览器中的一切都很好用,但是当在Webview组件内部实现时,新选项卡不会打开.
仅供参考:在我的Android应用程序中,我设置了以下内容:
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml我有以下权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
Run Code Online (Sandbox Code Playgroud)
我也试着setDownloadListener去抓下载.另一种方法被替换为WebViewClient()for,WebChromeClient()但行为是相同的.
我正在创建一个应用程序,允许大学生从应用程序而不是浏览器下载他们的学习材料.主页有很多主题名称.每个主题名称都会导致新的网页.所以,我用过WebViewClient.但是,在最后一页,当我点击*.ppt或*.pdf文件时,它会打开垃圾.
我希望在应用程序中下载这些文件.
我该如何实施 DownloadListener
package jiit.app;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class sm extends Activity
{
WebView browser;
protected void onCreate(Bundle anyvar)
{
super.onCreate(anyvar);
setContentView(R.layout.sm);
browser=(WebView)findViewById(R.id.webkit);
WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
browser.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
browser.setWebViewClient(new WebViewClient());
{
browser.loadUrl("http://www.sm.ividhya.com/j128/");
}
}
}
Run Code Online (Sandbox Code Playgroud) android ×4
javascript ×3
blob ×2
blobs ×1
bloburls ×1
fileapi ×1
html5 ×1
html5-video ×1
java ×1
url ×1
url-encoding ×1