如何在node.js中设置一个环境变量?(How can I set an environmental variable in node.js?)

如何在node.js中设置一个环境变量?

我宁可不依赖任何特定的平台,比如运行export或者cmd.exe的设置。


How can I set an environmental variable in node.js?

I would prefer not to rely on anything platform specific, such as running export or cmd.exe's set.


原文:https://stackoverflow.com/questions/10829433
2023-09-24 14:09

满意答案

假设您输入a<Enter>

您的缓冲读取器读取a字符:

char ch =(char)buf.read();

然后它读取行的结尾:

buf.readLine()

该行的结尾是一个空字符串。 因此,错误消息(你应该仔细阅读 ,因为它告诉你你想要解析为一个整数,从而解释了这个问题):

java.lang.NumberFormatException:用于输入字符串:“”


Solved it!!It's not a way u can use all the time but it can be used in simpler n shorter programs. Just accept the other values first then accept the char value(accept char in the end--after accepting all values of all other data types). The following is the code to accept a character to accept a character using BufferedReader:

    System.out.println("Enter the Character");
    char ch =(char)buf.read();

相关问答

更多

java - buffered reader helper class cant get second input(java - buffered reader helper class cant get second input)

Float.valueOf(String s)无法解析输入,则会抛出NumberFormatException 。 除了IOException之外,还要捕获一个。 在您的代码中,抛出NumberFormatException (如果输入无效)但未在方法内捕获,因此该方法将在完成finally块后立即返回。 Float.valueOf(String s) will throw a NumberFormatException if it can't parse the input. Catch tha...

通过缓冲读取器接受char值并避免NumberFormatException(accepting a char value through buffered reader and avoiding NumberFormatException)

假设您输入a<Enter> 您的缓冲读取器读取a字符: char ch =(char)buf.read(); 然后它读取行的结尾: buf.readLine() 该行的结尾是一个空字符串。 因此,错误消息(你应该仔细阅读 ,因为它告诉你你想要解析为一个整数,从而解释了这个问题): java.lang.NumberFormatException:用于输入字符串:“” Solved it!!It's not a way u can use all the time but it can be us...

Clojure:缓冲读取器for循环(Clojure: buffered reader in for loop)

for是惰性的,只返回最终将从文件中读取数据的序列的头部。 当您的repl 打印for的内容时,该文件已经关闭 。 你可以修复这个pu包裹在一个doall (with-open [rdr (reader "path/to/file")] (doall (for [line (line-seq rdr)] line))) 虽然这会使序列失效。 这是我的misc.clj中的一个函数的示例,它在结束时懒洋洋地关闭文件: (defn byte-seq [rdr] "c...

使用python io从缓冲流中编写行读取器(Composing a line reader from a buffered stream using python io)

在Python 2中,您希望避免使用TextIOWrapper对象,因为csv.reader()对象需要一个csv.reader() 。 它无法处理TextIOWrapper提供的unicode对象。 提供IOBase实现非常简单: class IOCompatibleKey(object): def __init__(self, s3_key): self.s3_key = s3_key def readable(self): retur...

NumberFormatException的(NumberFormatException)

那是因为6768886877对于一个int来说太大了。 使用long而不是。 long checkNumber = 0l; try{ checkNumber = Long.parseLong (phoneNumber); } catch (NumberFormatException e) { e.printStackTrace(); } That's because 6768886877 is too big of a number for an int. Use a long ins...

如何使用Java中的缓冲读取器再次读取文件?(How do I read a file again using buffered reader in Java?)

你这样做是通过递归调用run()函数,检查是否可以读取更多行 - 这是一个示例 // Reload the file when you reach the end (i.e. when you can't read anymore strings) if ((sCurrentLine = br.readLine()) == null) { run(); } you do this by calling the run() function recursively, after c...

缓冲读取器HTTP POST(Buffered Reader HTTP POST)

我同意Hans的观点,你应该使用一个标准的,经过充分测试的库来做到这一点。 但是,如果您正在编写服务器以了解HTTP,请参阅您想做的事情。 你真的不能使用BufferedReader,因为它会缓冲输入并可能从套接字读取太多字节。 这就是为什么你的代码挂起,BufferedReader试图读取比在套接字上可用的字节更多的字节(因为POST数据没有行结束),并且它正在等待更多字节(这将永远不可用) 。 简单地解析POST请求的过程是直接使用InputStream 对于标题中的每一行,一次读取一个字节,...

缓冲读取器读取文字直到字符(Buffered Reader read text until character)

使用Scanner会容易得多,您可以在其中设置分隔符: Scanner scan = new Scanner(new File("/path/to/file.txt")); scan.useDelimiter(Pattern.compile(";")); while (scan.hasNext()) { String logicalLine = scan.next(); // rest of your logic } It would be much easier to do w...

Android蓝牙缓冲读取器(Buffered Reader for Android Streaming from Bluetooth)

使用包装在BufferedInputStream的DataInputStream和readInt()方法。 这当然假设网络字节顺序是整数。 忘记所有这些arraycopy()东西。 Use a DataInputStream wrapped around a BufferedInputStream, and the readInt() method. This assumes network byte order in the integers of course. Forget all this...

有效数字的NumberFormatException(NumberFormatException on a valid number)

我认为那是因为你的字符串中有不可打印的字符。 所有不可打印的字符都是< '0' 。 你可以在这里看到哪些是可打印的,哪些不是: http://web.itu.edu.tr/sgunduz/courses/mikroisl/ascii.html 这就是你无法在输出中看到引发异常的字符的原因。 如果您不想为这些情况抛出异常,则必须更准确地进行比较,例如在if语句中检查这些字符或使用正则表达式。 无论如何,SO中有几个问题可以替换这些字符,如下所示: 从Java String中删除所有不可打印字符的最快...

相关文章

更多

Node.js视频教程

捷训Node.js入门教学视频,对初学者来说应该不错的,教学视频中包括javascript的基本知识的 ...

7月最新发布11.2.0.1.2 Patch set update

7月13日,11g release 2 的第二个补丁集更新发布了;9i的最终版本为9.2.0.8,10 ...

Rails设置环境变量

目前接触的环境变量分为2种,这里以sunspot中设置solr url为例 1. ENV['SOLR_ ...

How to set up Solr on Ubuntu 10.04 (or whatever)

How to set up Solr on Ubuntu 10.04 (or whatever) | ...

I18n的一个问题

升级了,2.2.2, 用了I18n. 问题来了。 以前model validation 出错的默认消 ...

Hadoop的I/O

1. 数据完整性:任何语言对IO的操作都要保持其数据的完整性。Hadoop当然希望数据在存储和处理中不 ...

Bentley.STAAD.RCDC.V8i.04.01.01.03 1CD

1、Bentley Multiframe Advanced V8i SS3 17.00.02.10 W ...

tomcat 下solr的java 环境变量 solr.solr.home 设置

修改apache-tomcat-7.0.39\bin\catalina.bat 增加set JAVA_ ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本