小编AvB*_*AvB的帖子

尽可能以最快的方式复制大文件

我试图找到一种以最快的方式复制大文件的方法......

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

public class FastFileCopy {


public static void main(String[] args) {
    try {
        String from = "...";
        String to = "...";
        FileInputStream fis = new FileInputStream(from);
        FileOutputStream fos = new FileOutputStream(to);
        ArrayList<Transfer> transfers = new ArrayList<>();
        long position = 0, estimate;
        int count = 1024 * 64;
        boolean lastChunk = false;
        while (true) {
            if (position + count < fis.getChannel().size()) {
                transfers.add(new Transfer(fis, fos, position, position + count));
                position += count + …
Run Code Online (Sandbox Code Playgroud)

java multithreading filechannel file-copying

2
推荐指数
1
解决办法
7275
查看次数

如何在HashMap中更改键的值?

你好,我怎么能改变一个键的值HashMap

请看这个:

private static final Map<String, DefaultMutableTreeNode> M = new HashMap<>();

public static DefaultMutableTreeNode executeCommand(int command, String item1, String item2) {
      switch (command) {
        //...
        case CommandsList.CREATE_CHILD:
            String name = item1;
            M.put(name, new DefaultMutableTreeNode(name));
            //...
            return M.get(root);
        case CommandsList.CHANGE_NAME:
            String newName = item2;
            //
            //what should I do here to replace name with newName???
            //
            return M.get(root);
        //...
    }
    return null;
}
Run Code Online (Sandbox Code Playgroud)

java hashmap map

1
推荐指数
1
解决办法
556
查看次数

标签 统计

java ×2

file-copying ×1

filechannel ×1

hashmap ×1

map ×1

multithreading ×1