用于Mac的Java文件输入 [英] File input in Java for Mac
本文介绍了用于Mac的Java文件输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import java.util.Scanner;
import java.io. *;
public class FileIO
{
public static void main(String [] args)
{
File Fred =新文件(David:\\mytext.txt);
try
$ div class =h2_lin>解决方案Mac OS中,使用/(正斜杠)而不是\(反斜杠)来分隔路径中的文件。硬盘位于/卷下。所以你的文件可能是/Volumes/David/mytext.txt。
We're learning file input and output in my programming class right now, but I have a Macbook Pro. I understand how to do it and I can do it on Windows but I'm having trouble finding out how to do it exactly for a Mac. I just can't seem to figure out what to put in the quotes for the 'File Fred = new File(" "); What do I need to put in the quotes to have it work? I have the file in the HDD named "David".
import java.util.Scanner;
import java.io.*;
public class FileIO
{
public static void main(String[] args)
{
File Fred = new File("David:\\mytext.txt");
try
{
解决方案 On Mac OS, you use "/" (forward slash) and not "\" (backward slash) to separate files in a path. Hard drives are located under "/Volumes". So your file is probably /Volumes/David/mytext.txt .
这篇关于用于Mac的Java文件输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文