Tag: 进度

如何在创建文件期间显示进度条?

如何在创建PDF文件期间单击按钮时显示进度条,并在创建文件后隐藏它? public class TwoFragment extends android.support.v4.app.Fragment { private View v; Intent chooser=null; String myInt=””; String ciao=””; private String string=””; private ProgressBar pdfProgress; ProgressTask task; public TwoFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout […]

Java SAX解析器进度监控

我正在用Java编写一个SAX解析器来解析维基百科文章的2.5GB XML文件。 有没有办法监视Java中的解析进度?

使用现有JProgressBar的Java ProgressMonitorInputStream

我正在玩Java的ProgressMonitorInputStream来监控数据流经BufferedInputStream。 这是我正在尝试的代码: InputStream in = new BufferedInputStream( new ProgressMonitorInputStream( new JFrame(),”Scanning”,new FileInputStream(dir.getSearchInputFile()))); 这完全正常,并弹出一个新的JFrame窗口,其中包含一个显示输入流进度的进度条。 有没有让ProgressMonitorInputstream更新另一个JFrame中存在的现有JProgressBar? 我尝试了各种方法,例如使用构造函数传递JProgressBar,或者尝试在参数中指定帧。 每次我尝试,我只是得到一个新的JFrame。 我错了吗? 任何投入将不胜感激。 谢谢

如何在java控制台(没有UI)中显示下载文件的百分比进度?

我的java代码部分如下。 while (status == DOWNLOADING) { /* Size buffer according to how much of the file is left to download. */ byte buffer[]; if (size – downloaded > MAX_BUFFER_SIZE) { buffer = new byte[MAX_BUFFER_SIZE]; } else { buffer = new byte[size – downloaded]; } // Read from server into buffer. int read = stream.read(buffer); if […]

如何在文件传输时创建进度条

import java.awt.Component; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.swing.JOptionPane; import javax.swing.ProgressMonitorInputStream; public class buckUpFile { private Component parentComponent; public void copyFile() { File srcFolder = new File( “C:\\Users\\ALLEN\\Workspace\\FINAL_LCTP_WORKBENCE_1.5”); File destFolder = new File( “C:\\Data Programing\\COPY_OF_FINAL_LCTP_WORKBENCE_1.5”); if (!srcFolder.exists()) { JOptionPane.showMessageDialog(null, “Directory does not exist.”); System.exit(0); } else […]

带有进度的HttpClient Post和MultipartEntityBuilder

我尝试使用HttpClient 4.3.3和MultipartEntityBuilder上传文件时实现进度 所以实际上我用以下代码执行一个post请求 HttpClientBuilder builder = HttpClientBuilder.create(); HttpClient httpClient = builder.build(); HttpPost httpPost = new HttpPost(uploadUrl); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); entityBuilder.addPart(“filea”, new FileBody(filea)); entityBuilder.addPart(“fileb”, new FileBody(fileb)); final HttpEntity entity = entityBuilder.build(); httpPost.setEntity(entity); HttpResponse response = httpClient.execute(httpPost); 知道如何从上传中获得实际进展吗? 我搜索了很多 – 但是示例是针对android而不是普通的java或旧版本的HttpClient并且对我不起作用…