当前位置: 首页>>代码示例>>Java>>正文


Java ProgressMonitorInputStream类代码示例

本文整理汇总了Java中javax.swing.ProgressMonitorInputStream的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitorInputStream类的具体用法?Java ProgressMonitorInputStream怎么用?Java ProgressMonitorInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProgressMonitorInputStream类属于javax.swing包,在下文中一共展示了ProgressMonitorInputStream类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkSHA256

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
private static boolean checkSHA256(File provingKey, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(provingKey))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,"Verifying proving key",is);
        pmis.getProgressMonitor().setMaximum(PROVING_KEY_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();
        return SHA256.equalsIgnoreCase(DatatypeConverter.printHexBinary(digest));
    }
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:19,代码来源:ProvingKeyFetcher.java

示例2: checkSHA256

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
private static boolean checkSHA256(File provingKey, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new RuntimeException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(provingKey))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,"Verifying proving key",is);
        pmis.getProgressMonitor().setMaximum(PROVING_KEY_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();
        return SHA256.equalsIgnoreCase(DatatypeConverter.printHexBinary(digest));
    }
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:19,代码来源:ProvingKeyFetcher.java

示例3: download

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
public void download() throws Exception {
	if (!downloadNeeded) { return; }
	logger.info("Downloading: "+this.downloadUrl);
	if (!DEBUG) {
		this.mkdir();
	    URL url = new URL(this.downloadUrl);
	    URLConnection urlConn = url.openConnection();
	    urlConn.setConnectTimeout(10000);
	    urlConn.setReadTimeout(10000);
	    InputStream is = urlConn.getInputStream();
	    ProgressMonitorInputStream pim = new ProgressMonitorInputStream(null, "Downloading "+ downloadUrl,is);
	    logger.info("File Size: "+this.remoteFileSize);
	    pim.getProgressMonitor().setMaximum((int) this.remoteFileSize);
	    pim.getProgressMonitor().setMillisToDecideToPopup(500);
	    logger.info("Starting Download...");
	    Files.copy(pim, localFile.toPath(),StandardCopyOption.REPLACE_EXISTING);
	}
}
 
开发者ID:open-power,项目名称:serverwiz,代码行数:19,代码来源:GithubFile.java

示例4: doInBackground

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
@Override
public Void doInBackground() {
	String rawString = configManager.getRawString();
	try {
		stream = new ProgressMonitorInputStream(null, (Object) "Flashing",
				new ByteArrayInputStream(rawString
						.getBytes(HacklaceConfigManager.HACKLACE_CHARSET)));
		ProgressMonitor progressMonitor = stream.getProgressMonitor();
		progressMonitor.setMaximum(rawString.length());
		progressMonitor.setProgress(0);
		progressMonitor.setMillisToPopup(0);
		animatorGui.setCursor(Cursor
				.getPredefinedCursor(Cursor.WAIT_CURSOR));
		flashExporter.write(stream);
	} catch (Exception ex) {
		JOptionPane.showMessageDialog(null, "Error flashing hacklace: "
				+ ex, "Error", JOptionPane.ERROR_MESSAGE);
	}
	return null;
}
 
开发者ID:Twissi,项目名称:Animator,代码行数:21,代码来源:FlashThread.java

示例5: load

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
/** Performs loading a serialized java object by poping a progress monitor.*/
@SuppressWarnings("unchecked")
public static <O> O load(String filename, Component parentComponent, String message) throws IOException, ClassNotFoundException {
    final FileInputStream fis = new FileInputStream(filename);
    final ObjectInputStream in;
    
    if(parentComponent!=null){
        final ProgressMonitorInputStream pm = new ProgressMonitorInputStream(parentComponent, message, fis);
        in = new ObjectInputStream(pm);
    }
    else{
        in = new ObjectInputStream(fis);
    }
    
    O r = (O) in.readObject();
    in.close();
    fis.close();
    return r;
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:20,代码来源:BinaryFiles.java

示例6: addDumpStream

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
private void addDumpStream(InputStream inputStream, String file, boolean withLogfile) {
    final InputStream parseFileStream = new ProgressMonitorInputStream(this, "Parsing " + file, inputStream);

    //Create the nodes.
    if(!runningAsJConsolePlugin || topNodes.size() == 0) {
        topNodes.add(new DefaultMutableTreeNode(new Logfile(file)));
    }
    final DefaultMutableTreeNode top = (DefaultMutableTreeNode) topNodes.get(topNodes.size()-1);
    
    if ((!withLogfile && logFile == null) || isLogfileSizeOk(file)) {
        logFile = new DefaultMutableTreeNode(new LogFileContent(file));
        if(!runningAsVisualVMPlugin) {
            top.add(logFile);
        }
    }
    setFileOpen(true);

    final SwingWorker worker = new SwingWorker() {

                public Object construct() {
                    synchronized (syncObject) {
                        int divider = topSplitPane.getDividerLocation();
                        addThreadDumps(top, parseFileStream);
                        createTree();
                        tree.expandRow(1);

                        topSplitPane.setDividerLocation(divider);
                    }

                    return null;
                }
            };
    worker.start();
}
 
开发者ID:irockel,项目名称:tda,代码行数:35,代码来源:TDA.java

示例7: RGBReader

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
/** Creates a new instance of LRGBReader */
public RGBReader(InputStream in)
{
	__in = new ProgressMonitorInputStream(null, "Reading...", in);
	__in.getProgressMonitor().setMillisToDecideToPopup(0);
	__in.getProgressMonitor().setMillisToPopup(0);
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:8,代码来源:RGBReader.java

示例8: decode

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
/**
 * Decodes a File into a Vector of LoggingEvents.
 *
 * @param url the url of a file containing events to decode
 * @return Vector of LoggingEvents
 * @throws IOException if IO error during processing.
 */
public Vector decode(final URL url) throws IOException {
  LineNumberReader reader;
  if (owner != null) {
    reader = new LineNumberReader(new InputStreamReader(new ProgressMonitorInputStream(owner, "Loading " + url, url.openStream())));
  } else {
    reader = new LineNumberReader(new InputStreamReader(url.openStream()));
  }

  Vector v = new Vector();

  String line;
  Vector events;
  try {
    while ((line = reader.readLine()) != null) {
      StringBuilder buffer = new StringBuilder(line);
      for (int i = 0; i < 1000; i++) {
        buffer.append(reader.readLine()).append("\n");
      }
      events = decodeEvents(buffer.toString());
      if (events != null) {
        v.addAll(events);
      }
    }
  } finally {
    partialEvent = null;
    try {
      if (reader != null) {
        reader.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  return v;
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:43,代码来源:XMLDecoder.java

示例9: getInputStreamWithProgressMonitor

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
public static InputStream getInputStreamWithProgressMonitor(InputStream input, Component parentComponent, String message)
{
	if (input == null)
		return null ;
	Frame owner = null;
	if (parentComponent == null) 
		owner = SwingUtils.tryFindSuitableFrameOwner () ;
	InputStream in = new BufferedInputStream(
			new ProgressMonitorInputStream(
					(parentComponent == null) ? (owner) : (parentComponent),
					message, input));
	return in;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:14,代码来源:FileUtils.java

示例10: loadFromFile

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
/**
 * Reads xmppdump formatted data from the given file, and loads it into the
 * embedded database.  Does not clear any pre-existing contents.
 * @param f File to be loaded.
 */
public void loadFromFile(final File f)
{
    try
    {
        // funnel file reads through a progress monitor
        final ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(
                xmpptrace.view.XmppTraceFrame.getInstance(), 
                "Reading " + f.getName() + "...",
                new FileInputStream(f));     
        pmis.getProgressMonitor().setMillisToPopup(0);

        // do the file loading on background thread so progmon will show
        new Thread() 
        {
            public void run()
            {
                // create a parser on an input stream from the file
                if (f.getName().endsWith(".pcap"))
                {
                    Database.this.readPacketsFromStream(
                    		new TcpDumpStreamParser(pmis));
                }
                else
                {
                    Database.this.readPacketsFromStream(
                    		new XmppDumpStreamParser(pmis));
                }
            }
        }.start();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:balthorium,项目名称:xmpptrace,代码行数:41,代码来源:Database.java

示例11: getProgressMonitorInputStream

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
public InputStream getProgressMonitorInputStream(InputStream in, int length, String msg) {
    ProgressMonitorInputStream pmin = new ProgressMonitorInputStream(parent, msg, in);
    ProgressMonitor pm = pmin.getProgressMonitor();

    if (length > 0)
        pm.setMaximum(length);
    return pmin;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:AbstractSwingGuiCallback.java

示例12: loadExcelFile

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
public void loadExcelFile(File f){
	try {
		int length = (int)f.length();
		JDialog d = new JDialog((Frame)null, "Loading File");
		JPanel p = new JPanel(new BorderLayout());
		p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
		d.setLocationRelativeTo(null);
		JProgressBar pb = new JProgressBar(0,length);
		p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
		p.add(pb);
		d.getContentPane().add(p);
		d.pack();
		d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		d.setVisible(true); 
		d.setAlwaysOnTop(true);

		Workbook wb = Workbook.getWorkbook(new ProgressMonitorInputStream(this,"Loading",new FileInputStream(f)));
		if (wb.getNumberOfSheets()==0)return;
		Sheet s = wb.getSheet(0);
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.getRows(); i++) {
			for (int j = 0; j < s.getColumns(); j++)
			{
					if (s.getCell(j, i).getType() == CellType.NUMBER && !s.getCell(j, i).getContents().matches("\\d*"))
					{
						pb.setValue(pb.getValue()+ 16);
						pb.repaint();
						sb.append(((NumberCell)s.getCell(j, i)).getValue()+"\t");
					}
					else
					{
						pb.setValue(pb.getValue() + 2*s.getCell(j, i).getContents().length() + 36);
						pb.repaint();
						sb.append(s.getCell(j, i).getContents()+"\t");
					}
			}
			sb.append("\n");
		}
		name.setText(f.getName().substring(0, f.getName().lastIndexOf('.')));
		input.setText(sb.toString());
		wb.close();
		d.dispose();

	} catch (Exception e) {
		JOptionPane.showMessageDialog(null, "Error loading file:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
		return;
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:49,代码来源:OtherDBInputDialog.java

示例13: loadVenueData

import javax.swing.ProgressMonitorInputStream; //导入依赖的package包/类
public Vector loadVenueData(Component parent) throws Exception {

		headers = null;
		Socket s = null;
		ProgressMonitor progress = null;
		Vector venues = null;

		try
		{
			StallInputStream stallInput = new StallInputStream();

			ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(
					parent, "Loading filter data from pente.org", stallInput);
			progress = pmis.getProgressMonitor();
            progress.setNote("Connecting to pente.org...");
			progress.setMillisToDecideToPopup(1);
            progress.setMillisToPopup(1);
            progress.setMaximum(15000);

			StringBuffer paramsBuffer = new StringBuffer();
	        StringBuffer requestBuffer = createHttpRequest(paramsBuffer, "/venues");

	        int len = 0;

        	s = getHttpResponseSocket(requestBuffer);
        	progress.setProgress(2000);
            progress.setNote("Downloading from pente.org...");

            // read past the http headers to the data
            InputStream in = s.getInputStream();
            String contentLength = getHeader("content-length:", in);
            if (contentLength != null) {
            	len = Integer.parseInt(contentLength);
            }
//            for (int i = 0; i < len; i++) {
//            	int b = in.read();
//            	if (b == -1) {
//            		System.out.println("error");
//            	}
//            }

        	progress.setMaximum(len);
        	stallInput.setInputStream(in);

        	ObjectInputStream objectIn = new ObjectInputStream(pmis);
			venues = (Vector) objectIn.readObject();

        } catch (Exception e) {
        	if (s != null) {
        		s.close();
            	s = null;
        	}
			if (!(e instanceof InterruptedException) && !(progress == null || !progress.isCanceled())) {
				throw e;
			}
        }

        return venues;
	}
 
开发者ID:dweebo,项目名称:pentedb,代码行数:60,代码来源:PlunkHttpLoader.java


注:本文中的javax.swing.ProgressMonitorInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。