0

So I have this program and I would want to have Java figure out the username by itself.

import java.io.*; import java.nio.file.Files; public class Demo { public static void main(String[] args) throws IOException { File file = new File("/Users/angel/Desktop"); String[] files = file.list(); for (String string : files){ for (int i = 0; i < files.length; i++) { if(String.valueOf(string).contains(".png")){ File sourceFile = new File("/Users/angel/Desktop/" + string); File destinationFile = new File("/Users/angel/Desktop/Screenshots/Screenshot" + string ); Files.move(sourceFile.toPath(), destinationFile.toPath()); string = ""; } } } } } 
2
  • Does this answer your question? Recommended way to get hostname in Java Commented May 6, 2021 at 15:15
  • "Computer Name" and "User Name" are not the same things. Commented May 6, 2021 at 15:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.